Rules Vs Checks?

Jan 23, 2007

Hi experts,

What is the difference between, Creating rules and creating checks on a field?

They both look the same.

Regards
sachin

Don't sit back because of failure. It will come back to check if you still available. -- Binu

View 9 Replies


ADVERTISEMENT

FK Checks

Jul 20, 2005

Suppose you have two (or more) tables with foreign key constraints. Myquestion is thus:Is it better to check if the fk exists before you try to perform theinsert or let SQL do it for you?On one hand, if you check yourself and the key does not exist you cangracefully handle it (maybe exit out of method with error). If you letSQL do it, the server will throw an error which cannot be suppressed.On the performance side, you doing the check will incur a slight (VERYslight) hit since SQL will ALSO check anyways.

View 3 Replies View Related

Health Checks On SQL

Jul 15, 2004

I'm starting to collect and develop some scripts that will tell me the health and welfare of my MSSQL 2k server. I have a few for blocks, db size, who is on and what they are currently running.

I was wondering if you guys could share some of the scripts you guys use to watch the health of your servers.

Thanks,
DMW

View 1 Replies View Related

Integrity Checks

Aug 21, 2002

On weekends I have Integrity Checks scheduled to run. Many of these fail for individual databases because users do not log off and the databases cannot be switched to single user mode.

I have checked Books-on-line and have not yet stumbled onto a TSQL command that breaks the connections.

Is there a TSQL command to do this? If not, how can these connections be broken?

View 2 Replies View Related

Health Checks

Jul 15, 2004

I'm starting to collect and develop some scripts that will tell me the health and welfare of my MSSQL 2k server. I have a few for blocks, db size, who is on and what they are currently running. I was wondering if you guys could share some of the scripts you guys use to watch the health of your servers.

Thanks,
DMW

View 1 Replies View Related

Integrity Checks Failing

Apr 21, 2003

I have a few databases on this Windows 2000 Server running
SQL 2000 which were detached from SQL 7.0 and attached to
SQL 2000.
The problem is the Maintenance Plans (Integrity Checks
keep failing on SQL 2000. I 'DTS'ed a SQL 7.0 database to
this SQL 2000 server and ran the Maintenance Plans on that
database. Works fine only for the DTS'ed database.
What am I missing ???
:confused:

View 5 Replies View Related

Integrity Checks Job Failed

Jul 29, 2004

Hello, I had a DB Maintenance plan, the schedule is every day, but today I found teh 'Integrity checks job is failed". What is that mean? How to check this. Thanks.

View 14 Replies View Related

Num Of Checks Written In 4 Day Period For More Than $400

Apr 25, 2006

I have a transaction table which has Date as datetime field, amount and account number. i want to find out count of checks that were written in a period of 4 days which exceeded i.e. > $400, between 401 and 500, > 501 for a single month. the table has data for more than a year and i want the results then grouped in monthly format like in
OCT between 300 & 400 #30 (30 customers gave checks total worth $300-$400 within any 4 consecutive days period in the month of OCT )
between 400 & 500 # 20
> 501 # 10

NOV between 300 & 400 #30
between 400 & 500 # 20
> 501 # 10

and so on for a 6 month period.

View 1 Replies View Related

Integrity Checks Job Failed

May 10, 2006

Activity: Check Data and Index Linkage
Error Number: 3624
Severity: 20
State: 1

The errorlog has this:

SQL Server Assertion: File: <p:sqltdbmsstorengdrsinclude
ecord.inl>, line=1447
Failed Assertion = 'm_SizeRec > 0 && m_SizeRec <= MAXDATAROW'.

There is a dump file generated also.

I had run DBCC CHECKDB and no error is found.

Any help is appreciated.

Thanks

View 3 Replies View Related

Integrity Checks Job Failing

May 7, 2007

Hi,

SQl Server 7

I have Daily User DB Integrity Checks job running daily
From past 2 days i am getting below error.

[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 0 allocation errors and 35 consistency errors in table 'Prod_Hist' (object ID 2098106515).
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 0 allocation errors and 99 consistency errors in database 'Ucatalog'.
[Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKDB (Ucatalog repair_fast).
[Microsoft][ODBC SQL Server Driver][SQL Server]DBCC execution completed. If DBCC printed error messages, contact your system administrator.


Please suggest..

Thanks in Advance
Adil

View 1 Replies View Related

Daily/Weekly Checks

Jun 24, 2008

What daily/weekly checks do you guys currently perform on your servers and databases?

I recently ran across with an article from SQLServerCentral that listed a couple of daily checks that I'm thinking about implementing on my environment, and some of them are:
DB Missing Recent Backup - Report
DB Missing Recent Log Backup - Report
Drives Low on Disk Space - Report
Error Log Messages Report - Report
Instance Recently Restarted - Report
Job Failures - Report
Large Databases Log File - Report

I already have in place:
Verify is SQL Agent Service is running
Check Disk Space Available

Since I'm going to spend some time on this, I was wondering if there's anything else that you guys have in place or any other 'nice to have' that you guys also might have, so I don't leave anything behind...

Thanks!


---
http://www.ssisdude.blogspot.com/

View 5 Replies View Related

Conditional Checks In SSIS.

Apr 11, 2007

I have two connections in a package pointing to two different databases
on the same server. I have to insert records from 'DB1' table 'Gender1'
to 'DB2' table 'Gender2'. Before I do that though, I have to make sure
the minimum value (of all the Gender Keys that are going to be
inserted) of 'DB1' 'GenderKey' (which is an identity field) is greater than the
maximum value of DB2-GenderKey (which is a primary key but not an
identity field). How can I do this simple check? I have to do this process for many different tables ....... Gender table is just an example. If someone can give an detailed explanation on which tasks to use and how to use them (as I am relatively new to SSIS) that'd be great.

View 17 Replies View Related

Constraint Checks After Insert

Feb 27, 2008



Hi all,

I'm trying to use a custom check constraint to insert into a table. I have created a function that checks an item against a authorization date as well and I've coupled this into the constraint. So for example, my function starts:




Code Snippet
ALTER FUNCTION {function1} (@ItemID INT, @AuthDate DATETIME)
RETURNS INT
AS
BEGIN

DECLARE @Ret INT
SET @Ret = 0
IF NOT EXISTS(SELECT top 1 ItemID FROM {table1}
Where b1.ItemID = @ItemID
AND @AuthDate <= ISNULL(b1.expirydate, @AuthDate))
BEGIN
SET @Ret = 1
END
ELSE
BEGIN
SET @Ret = 0
END

RETURN(@Ret)
END
GO



Now i couple that into a check constraint for the same table:




Code Snippet
ALTER TABLE {table1} ADD CONSTRAINT {contraint_name} CHECK (([function1]([ItemID], [AuthorizedDate])=(1)))
GO








Now, when i insert a record into this table with an Authorized Date greater than the ItemDate it should set the @ret value to 1. This is being passed back to the constraint should set 1=1 which is true and therefore should allow an insert, however, i cannot do this. I think this is because it inserts the record and THEN does the check which makes it fail. Is there anyway to do this check before the INSERT without having to use a trigger? I dont want to use a trigger because when we're doing an insert for bulk rows, performance decreases correct?



View 3 Replies View Related

Help - Conditional Checks Within A SQL Query - Other Ways Of Doing It?

Jun 13, 2007

I'm trying to simplify a SQL Stored Procedure.The query accepts an int, @ItemTypeID intI have the Query:SELECT ... FROM ItemList WHERE ItemTypeID = @ItemTypeIDor, if @ItemTypeID is 0,SELECT ... FROM ItemList Is there a way to do this query without doing:IF @ItemTypeID = 0BEGIN   ...SELECT QUERY...ENDELSEBEGIN   ...SELECT QUERY...END? 

View 5 Replies View Related

SQLMaint Integrity Checks Failure

Aug 30, 2005

My SQLMaint integrity checks consistently fail when the "Repair any minor problems" option is checked. The reported reason is that the database must be in single user mode. This doesn't seem practical. Am I missing an option somewhere?

View 1 Replies View Related

Help - Script That Checks For OFFLINE Database

Sep 21, 2006

Hello ,

I have got a script which checks for the databases that are offline. and mails the dba when any of the database is offline.

When I schedule the job , for every hour , it gives me an blank mail only with the subject ' status of database on testsql' even though no databases are offline.

So how can I change the script , so that it mails the dba only when a database is offline even though its scheduled every hour or half an hour.

The script is:

Set NoCount on
DECLARE @dbname VARCHAR(100)
deCLARE @Status varchar(100)
Declare @Message VARCHAR(8000)
DECLARE @date varchar(100)
set @date = convert(varchar(100), getdate(),109)
set @Message = ''DECLARE dbname_cursor
CURSOR FOR SELECT [name], CONVERT(varchar(30),DATABASEPROPERTYEX(name,'Statu s'))
as [Status] FROM master..sysdatabases WHERE CONVERT(varchar(30),DATABASEPROPERTYEX(name,'Statu s')) = 'OFFLINE'
order by name
OPEN dbname_cursor
FETCH NEXT FROM dbname_cursor INTO @dbname, @Status
WHILE
@@FETCH_STATUS = 0
BEGIN select @message = @message + @@Servername + '-' + @dbname + ' - ' + @Status + Char(13)+ ‘- ‘ + @date
FETCH NEXT FROM dbname_cursor INTO @dbname, @Status
END
CLOSE dbname_cursor
DEALLOCATE dbname_cursor

print @message
EXEC master.dbo.xp_smtp_sendmail
@FROM = N'testsql2000@is.depaul.edu',
@TO = N'dvaddi@depaul.edu',
@server = N'smtp.depaul.edu',
@subject = N'Status of the Database on Testsqlserver!',
@type = N'text/html',
@message = @message


Thanks

View 8 Replies View Related

Dev Code For Database Exists Checks

Mar 1, 2006

I want to check to see if a database exists in SQL Server 2005 Express... using VB.NET (or C#)... Can not use the SQLConnection Object... because I get a Failed Login Attempt... regardless if the DB does not exist or if it is because the User Login is incorrect

Is there some way to check to see if the Database exists (is attached) to the SQL Server 2005 Express Engine?

ward0093

View 3 Replies View Related

Integrity Checks Job Question In Sql 2000

Dec 3, 2007

The integrity checks job on the user databases failed over the weekend and here is the error I got from the report:
Database DB_Stores: Check Data and Index Linkage...
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 7919:
[Microsoft][ODBC SQL Server Driver][SQL Server]Repair statement not processed.
Database needs to be in single user mode.
The following errors were found:
[Microsoft][ODBC SQL Server Driver][SQL Server]Repair statement not processed.
Database needs to be in single user mode.
** Execution Time: 0 hrs, 0 mins, 1 secs **
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 5070: [Microsoft][ODBC SQL Server Driver][SQL Server]
Database state cannot be changed while other users are using the database 'DB1'
[Microsoft][ODBC SQL Server Driver][SQL Server]ALTER DATABASE statement failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]sp_dboption command failed.
Googled the issue and found some articles on this issue, but wanted to also run it by you.
I looked at the maint plan properties and under the integrity tab of the maint plan attempt to repair any problems is checked, this is what I think:
Since attempt to repair is checked, the db was trying to repair the issue and since users were logged into the system
it could'nt repair the issue as the system needs to be in single user mode. I think if we uncheck the attempt to repair
option, then the job would run fine.
But is this the best way to do? how about the errors it was trying to repair? Do we have to fix the error's it was trying to
fix later by changing the db to single user mode.
PLease let me know your ideas, thanks!!

View 1 Replies View Related

TSQL Checks File Existence?

Sep 3, 2007

Hi,


Does TSQL provide methods to check if a file exists?


For example, a TSQL script will read data in a .dbf file into SQL Server. It will check if the file exists before read. How to do this check?


Thank you.

View 1 Replies View Related

SQL 2012 :: Optimal Settings For DBCC Checks?

Aug 5, 2014

I have a VM set up for offloading DBCC checks. Specs are below. I've read through this, but I'm not seeing the performance gains by enabling the trace flags and using the physical only switch.

Is the whole drawback that I'm on SATA storage? Is there a VM configuration with the CPU I can/should change? I've been playing with MAXDOP trying to see if I can get any benefits but I'm not seeing a much.

wait_type wait_time_spctrunning_pct
CXPACKET 561191.4228.7128.71
OLEDB 387136.7619.8148.52
PAGEIOLATCH_SH 340674.5817.4365.95
TRACEWRITE 321598.8416.4682.41

[code].....

View 9 Replies View Related

SQL 2012 :: Backup Job And Integrity Checks Are Failing?

Sep 27, 2015

I am using sql server 2012 with HADR (Always on with sql cluster).

We have database maintenance plans through wizard for full backup & DBCC CHECK DB. It was running successfully but it failed with the below error

Execute SQL Task Description: Failed to acquire connection "Local server connection". Connection may not be configured correctly or you may not have the right permissions on this connection.

(A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)).

(A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)).

I can able to take the backup from query window. It is succesful. The Sql Agent has full permissions. I don't think there are any recent changes happen.

View 9 Replies View Related

Automating Process Of Database Integrity Checks

Feb 1, 2007

Hi,
I want to automate the process of database integrity checks in sql server any suggestions how to do

View 1 Replies View Related

Transact SQL :: Run A Query That Checks A Column To See If Its Numeric

Jul 14, 2015

I am trying to run a query that checks a column to see if its numeric. If it is, it should cast as a float, if its not numeric it should return 0.

select case when (isnumeric(Ref)=1) THEN select (cast(Ref,float) )
else (0) as outputfrom #table

but its returning an error.

View 5 Replies View Related

Script Which Checks When Running Out Of Auto-growth Extents?

Feb 24, 2015

I'm looking for hints/tips/url for a script which can be run a few times per day and either sends an email or alert for the following condition:

Script would function like:

[URL]

Databases - Dynamic Log File Growths Remaining Alarm

Dynamic Log File Growths Remaining alarm becomes active when a non fixed size log file in any database is in danger of running out of space to grow. It is raised when a log file is almost full and the file cannot automatically grow enough to relieve the problem.

We have our databases with Enable Autogrowth (in Megabytes), and then a Maximum File Size (Limited to a MB value).

Example: If one of the database logs (or possibly filegroup primary) picks up another extent and is about 5 extents (arbitrary value) away from running out of growth room, an alert would be sent to an email address/profile.

P.S. Yes, there are multiple databases on this one instance and the script should loop to run through all of them.

View 2 Replies View Related

Stored Procedure That Checks To See Whether A Value Exists And Only Enters Data If It Doesn't

Feb 4, 2008

Hi All,

I Have a nifty little stored procedure that takes data from an ASP form post
and inserts the data into two tables. However what I really need this to do
before the insert is check whether there is already a record that matches
some of the criteria, and if so returns an error "This Username already
exists" and only if there isn't a record that matches the criteria is the
record inserted.

my current stored procedure looks like this -

Code Snippet@siteid int,@companyname nvarchar(50),@address nvarchar(500),@phone nvarchar(50),@fax nvarchar(50),@email nvarchar(225),@url nvarchar(225),@companytype nvarchar(50),@billingcontact nvarchar(50),@name nvarchar(50),@AccountType nvarchar(50),@PASSWORD nvarchar(50),@AccountLive nvarchar(50),@EmployeeLevel nvarchar(50)ASDeclare @NewID INTINSERT INTO dbo.JBClient(JBCLSiteID, JBCLName, JBCLAddress, JBCLPhone, JBCLFax, JBCLEmail, JBCLCompanyType, JBCLURL, JBCLAccountType, JBCLAccountlive, JBCLBillingContact)VALUES (@siteid, @companyname, @address, @phone, @fax, @email, @companytype, @url, @AccountType, @AccountLive, @billingcontact)SELECT @NewID = SCOPE_IDENTITY()INSERT INTO dbo.JBEmployee(JBEClientID, JBESiteID, JBEName, JBELevel, JBEUsername, JBEPassword, JBEAddress, JBEPhone)VALUES (@NewID, @siteid, @name, @EmployeeLevel, @email, @PASSWORD, @address, @phone)
The values that i need to check against are -

@siteid
@email

in the table dbo.JBEmployee against columns JBESiteID & JBEUsername

What i would really like to do if a record exists is return the user to an
ASP page, which contains all of the variables previously enterred -,

@siteid int,
@companyname nvarchar(50),
@address nvarchar(500),
@phone nvarchar(50),
@fax nvarchar(50),
@email nvarchar(225),
@url nvarchar(225),
@companytype nvarchar(50),
@billingcontact nvarchar(50),
@name nvarchar(50),
@AccountType nvarchar(50),
@PASSWORD nvarchar(50),
@AccountLive nvarchar(50),
@EmployeeLevel nvarchar(50)

together with a message that says "This Username already exists"

Does anyone have any idea how to do this???

Many thanks

View 6 Replies View Related

Integration Services :: Data Type Checks In SSIS Package

Oct 13, 2015

I have to perform several data checks before loading data into target table. For example I am having 1 flat file with below column

Id Name Age
Int Varchar(100)  Int

My requirement is to create  package, checks will be performed on each record, column of the files. Any records which failed the checks considered as error records and will be written to the exception table.

View 4 Replies View Related

Sql Rules And Udt

Sep 6, 2007

hello, i've just started playing around with rules and udtis it possible to alter rule?are rules 'slower' compared to check constraint?

View 7 Replies View Related

User Rules

Feb 22, 2001

Please forgive my ignorance, however I am 2 months new to SQL-Server 2000.

Is there a way to create a rule specific to a user such that he can only SELECT from a table where a field equals a specific value.

In other words user Joe types in: SELECT * FROM SALES_BY_LOCATION. Because Joe's territory is Los Angeles, I want a rule that only retrieves sales data from Los Angeles.

View 1 Replies View Related

Rules On A Table

Jun 11, 2004

In My table i'm collecting information about our customers.In that i have fields zip and phone.So i wanted to implemement a rule that zip should be atlaest of of 5 characters and phone should be 13 characters Including '-'s(333-333-3333).How can i implement these two rules on my table.

View 9 Replies View Related

Do You Like To Break The Rules ?

Oct 6, 2004

Not long ago I accountered this situation: I had two databases on "MS SQL Server". In one of the databases there was a nomenclature with very large primary key.
I had to transport that nomenclature and transform the wide PK into single identity column into the other database.

I decided to use a function for that transformation. BUT that function had to mark somewhere which combination of the PK columns is relative to which identity value. BUT functions CAN'T WRITE under MSSQL.
So I took the challenge and mine all sources of information. The result was a function "Exec4Fun" that breaks the rule.
I suppose that with this function it's possible to avoid the restriction for triggers, which prevents writing in the triggering table? (not tested yet)

If someone needs such tools, just write back your e-mail and I'll send some code.

All the best and have fun :)

View 4 Replies View Related

HELP!!:about The MS Association Rules

May 14, 2006

When i use the MS association rules ,i don't know how it is worked on the background .I stuy the Fp-Growth algorithm , but there're some questions , I don't kown what's the meaning of transcation database. who can give me one example ? thanks .I know we can store the data in relation database,but in basket Analysis ,how a transaction stroed in relation database?

View 3 Replies View Related

Association Rules

Dec 3, 2006

1) I use the identifier of transaction and attribute in one table.

Do I can to build a association rules structure without the use of the nested tables?

I tried - did not turn out...

2) As it is necessary to use a main and child table, can not build a prediction query.

When I try to add the predict column in a criteria/argument (Field=PredictSupport), i'll given message:

"Nested table column cannot be used as an argument in a data mining function."

I can not use other columns, because they are not predicable.

View 4 Replies View Related

Applying Rules

Apr 18, 2008

In my package i have column called "optinout" coming from source file which has the value "start" and "stop", now in my destination table i have a column called "contact permission code" to which i need to apply a business rule based on the value in column "optinout" the rule is as stated "Contact Permission Code" is OptOut if "OptInOut" value is "STOP" else OptIn.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved