Comments
3 comments
-
I think that "DROP and CREATE" option can help you achieve that: https://documentation.red-gate.com/sc/setting-up-the-comparison/setting-project-options#Settingprojectoptions-AddDROPandCREATEforrerunnablescripts
-
Sergio R said:I think that "DROP and CREATE" option can help you achieve that: https://documentation.red-gate.com/sc/setting-up-the-comparison/setting-project-options#Settingprojectoptions-AddDROPandCREATEforrerunnablescripts
-
I understand, I'm afraid that DROP and CREATE is the closest option available currently in SQL Compare.
If you wish to, you can suggest that as an improvement on our Uservoice site at https://redgate.uservoice.com/forums/141379-sql-compare
Add comment
Please sign in to leave a comment.
What I'd like for it to do is...
With object exists checks, provide a way to do IF NOT EXISTS create a procedure/function stub with an empty body. Follow that with the actual method body in an ALTER statement rather than CREATE. This works whether the procedure/function in question exists or not on the server. Permissions can follow the creation of the stub, since alter statements do not change permissions.
It might look something like this...
BEGIN
EXEC sp_executesql N'CREATE PROCEDURE [dbo].[myProc] AS BEGIN RETURN; END'
PRINT N'Adding procedure [dbo].[myProc]'
EXEC sp_executesql N'GRANT EXECUTE ON [dbo].[myProc] TO [myUser]'
PRINT N'Altering permissions on [dbo].[myProc]'
END;
ELSE
PRINT N'Updating procedure [dbo].[myProc]'
GO
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[myProc]
(@MyParam VARCHAR(50))
AS
BEGIN
PRINT @MyParam;
END;
'
GO
Currently, I have been modifying the script output but was wondering if it's possible for the script generation to do it.