"GO" batch text in SQL Compare

Is there any way to influence the use of "GO"s in the generated change script?

Thanks, Don

Comments

  • Eddie DEddie D Posts: 1,807 Rose Gold 5
    edited April 5, 2017 8:31AM
    Hi Don

    Thank you for your forum post.

    Are you able to explain further what you are seeking in reference to the GO keyword in the deployment script?

    There is no option to set or influence the GO keyword. There is a GO statement after the creation or change to each object as per the simple example:
    PRINT N'Creating schemas'
    GO
    CREATE SCHEMA [HumanResources]
    AUTHORIZATION [dbo]
    GO
    IF @ERROR <> 0 SET NOEXEC ON
    GO
    CREATE SCHEMA [Person]
    AUTHORIZATION [dbo]
    GO
    IF @ERROR <> 0 SET NOEXEC ON
    GO
    CREATE SCHEMA [Production]
    AUTHORIZATION [dbo]
    GO
    IF @ERROR <> 0 SET NOEXEC ON
    GO
    CREATE SCHEMA [Purchasing]
    AUTHORIZATION [dbo]
    GO
    IF @ERROR <> 0 SET NOEXEC ON
    GO
    CREATE SCHEMA [Sales]
    AUTHORIZATION [dbo]
    GO
    IF @ERROR <> 0 SET NOEXEC ON
    GO
    CREATE SCHEMA [tSQLt]
    AUTHORIZATION [dbo]
    GO
    

    (note that @ERROR should be @ @ERROR, avoiding formatting problem with double @)

    OR
    BEGIN TRY
       EXEC sp_addextendedproperty N'MS_Description', N'Default constraint value of GETDATE()', 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'CONSTRAINT', N'DF_ProductCategory_ModifiedDate'
    END TRY
    BEGIN CATCH
       DECLARE @msg nvarchar(max);
       DECLARE @severity int;
       DECLARE @state int;
       SELECT @msg = ERROR_MESSAGE(), @severity = ERROR_SEVERITY(), @state = ERROR_STATE();
       RAISERROR(@msg, @severity, @state);
    
       SET NOEXEC ON
    END CATCH
    GO
    BEGIN TRY
       EXEC sp_addextendedproperty N'MS_Description', N'Default constraint value of NEWID()()', 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'CONSTRAINT', N'DF_ProductCategory_rowguid'
    END TRY
    BEGIN CATCH
       DECLARE @msg nvarchar(max);
       DECLARE @severity int;
       DECLARE @state int;
       SELECT @msg = ERROR_MESSAGE(), @severity = ERROR_SEVERITY(), @state = ERROR_STATE();
       RAISERROR(@msg, @severity, @state);
    
       SET NOEXEC ON
    END CATCH
    GO
    

    Many Thanks
    Eddie
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
Sign In or Register to comment.