Ninetiger blog

-- my reminder

Sql script checks: before create table or sp

1. Check table exists before create:

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'tableName')

BEGIN

.....

END

2. Check sp exists before create

IF NOT EXISTS (SELECT * FROM sys.procedures WHERE object_id = OBJECT_ID(N'[dbo].[spName]'))

BEGIN

....

END

Comments:

Back to top