July 2, 2008 at 4:14 pm
Hi all!!
I am writing simple test scripts to see if columns and constraints were created. I know that I can find out info using the sp_helpconstraint stored procedure, but I need to check specifically for each. Here is an example of my test for column creation and I am wondering is there a similar way to do it for the constraints?? Thank you in advance, as always!!
IF EXISTS (SELECT * FROM dbo.syscolumnssc,
dbo.sysobjectsso
WHERE so.id= sc.id
and so.name = 'ExistingTable'
and sc.name = NewColumn'
and so.xtype = 'U' )
BEGIN
SELECT PassFail = 'PASS: NewColumn has been added to ExistingTable table',
'Miss Dev' AS Developer,
getdate() as [Last Modified]
END
ELSE
BEGIN
SELECT 'Fail: NewColumn has NOT been added to ExistingTable table',
'Miss Dev' AS Developer,
getdate() as [Last Modified]
END
July 2, 2008 at 4:43 pm
Try using INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE or INFORMATION_SCHEMA.CHECK_CONSTRAINTS. There are a few other similar views that will be helpful. See BOL.
July 3, 2008 at 7:55 am
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply