detecting create vs alter differences
rchan
Posts: 11
We are using SQLCompare to compare against a database and scripts folder.
In our scripts for for objects such as Stored procedures, views, functions, we currently use the "IF NOT EXIST... create object ... GO ... alter object" structure to create/alter the object.
This is different than the standard approach of IF EXISTS DROP... CREATE. We don't do the latter approach because we can't risk accidently losing permissions on this object (from the DROP statement) when deploying this to production.
However, SQL Compare will always complain about a difference in this object due to the difference in "CREATE" versus "ALTER".
Any suggestions on how to get SQL Compare to NOT report a difference?
Thank you
Ray
EXAMPLE:
IF NOT EXISTS (
SELECT *
FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'ufn_MyFunc') AND xtype IN (N'P', N'V', N'FN', N'TF', N'TR'))
EXEC('CREATE FUNCTION ufn_MyFunc() RETURNS varchar(5) AS BEGIN return ''empty'' END')
GO
ALTER FUNCTION ufn_MyFunc
... etc...
In our scripts for for objects such as Stored procedures, views, functions, we currently use the "IF NOT EXIST... create object ... GO ... alter object" structure to create/alter the object.
This is different than the standard approach of IF EXISTS DROP... CREATE. We don't do the latter approach because we can't risk accidently losing permissions on this object (from the DROP statement) when deploying this to production.
However, SQL Compare will always complain about a difference in this object due to the difference in "CREATE" versus "ALTER".
Any suggestions on how to get SQL Compare to NOT report a difference?
Thank you
Ray
EXAMPLE:
IF NOT EXISTS (
SELECT *
FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'ufn_MyFunc') AND xtype IN (N'P', N'V', N'FN', N'TF', N'TR'))
EXEC('CREATE FUNCTION ufn_MyFunc() RETURNS varchar(5) AS BEGIN return ''empty'' END')
GO
ALTER FUNCTION ufn_MyFunc
... etc...
Comments
Red-Gate support