Hi
By default, SCA generated the Stored Procedure Script as DROP + CREATE
IF OBJECT_ID('[dbo].[My_SP]') IS NOT NULL
DROP PROCEDURE [dbo].[My_SP];
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[My_SP]
AS
SELECT xx66 FORM YY
GO
I want to generate script CREATE + ALTER
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[My_SP]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[My_SP] AS'
END
GO
ALTER PROCEDURE [dbo].[My_SP]
BEGIN
SELECT xx66 FORM YY
END
GO
The problem with DROP + CREATE approach is, we lost all the grant permission to stored procedure.
on the other hand, with CREATE + ALTER approach we will not lost any grant permission.
I know, i can use post-deployment to apply grant permission again. Is CREATE + ALTER possible with SCA.
Thanks
Gill
Comments
12 comments
-
any help.
-
Please help...
-
Hi,
Apologies for the delayed response. This is currently a limitation of SQL Change Automation programmable object handling (See permission handling under https://documentation.red-gate.com/sca/developing-databases/concepts/migrations/programmable-objects).
You can manually alter the programmable object but it is then liable to be overwritten if you are not careful. I have raised an internal ticket for this and we will see if there are any improvements that can be made here. We will get back to you when we know.
Kind Regards,
Ivo Miller -
Hi,
Apologies for the delayed response. This is currently a limitation of SQL Change Automation programmable object handling (See permission handling under https://documentation.red-gate.com/sca/developing-databases/concepts/migrations/programmable-objects).
You can manually alter the programmable object but it is then liable to be overwritten if you are not careful. I have raised an internal ticket for this and we will see if there are any improvements that can be made here. We will get back to you when we know.
Kind Regards,
Ivo Miller -
Hi,
Apologies for the delayed response. This is currently a limitation of SQL Change Automation programmable object handling (See permission handling under https://documentation.red-gate.com/sca/developing-databases/concepts/migrations/programmable-objects).
You can manually alter the programmable object but it is then liable to be overwritten if you are not careful. I have raised an internal ticket for this and we will see if there are any improvements that can be made here. We will get back to you when we know.
Kind Regards,
Ivo Miller -
Hi,
Apologies for the delayed response. This is currently a limitation of SQL Change Automation programmable object handling (See permission handling under https://documentation.red-gate.com/sca/developing-databases/concepts/migrations/programmable-objects).
You can manually alter the programmable object but it is then liable to be overwritten if you are not careful. I have raised an internal ticket for this and we will see if there are any improvements that can be made here. We will get back to you when we know.
Kind Regards,
Ivo Miller -
Hi,
Apologies for the delayed response. This is currently a limitation of SQL Change Automation programmable object handling (See permission handling under https://documentation.red-gate.com/sca/developing-databases/concepts/migrations/programmable-objects).
You can manually alter the programmable object but it is then liable to be overwritten if you are not careful. I have raised an internal ticket for this and we will see if there are any improvements that can be made here. We will get back to you when we know.
Kind Regards,
Ivo Miller -
Ok Thanks Ivo
-
@GurpreetGill - what version of SQL Server are you using? We are investigating changing the programmable object format to the following, but this syntax is only supported in SQL Server 2016+.CREATE OR ALTER PROCEDURE [dbo].[My_SP]ASSELECT xx66 FORM YYGO
-
@David Atkinson That would be great if you would be able to generate the Create or Alter syntax when the target SQL Version is 2016+Thanks,Eric
-
That would be great if you would be able to generate the Create or Alter syntax when the target SQL Version is 2016+
-
Setting programmable objects to use CREATE OR ALTER is now a configurable setting (UseCreateOrAlterForRerunnableScripts) as described in the documentation.
Add comment
Please sign in to leave a comment.