Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 check constraint before insert

Author  Topic 

gpc44
Starting Member

35 Posts

Posted - 2011-12-02 : 11:47:20

Hi,
is there a way to check constraints before the INSERT INTO command is executed?
I would like inserts only valid data before a Bulk Insert fails complete (Rollback). Not valid records should be marked in.

Thanks
Nicole

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-12-02 : 12:09:43
Only using the obvious query to emulate the constraints.
You can put a try catch block around the statement then run the checks and exclude rows only if the insert fails maybe (maybe in an instead of trigger but I think that might have problems).

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-02 : 12:10:06
its possible using a INSTEAD OF INSERT trigger

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -