How to Stop SSMS 2012 from scripting SPs using sp_executesql

前端 未结 4 1948
灰色年华
灰色年华 2021-02-18 15:34

I realise this is a very similar question to Stop SSMS from scripting SPs using sp_executesql?

However, they seem to have changed the behaviour with SSMS 2012.

I

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-18 16:29

    I also struggled with the same issue. If you need to script out the objects for an entire database, you might want to consider ApexSQL Script. I tried several tools and ApexSQL scripted the objects exactly how I needed. (if object exists, then drop. create the object). I believe it also works from the command-line. Note, it is shareware; I've only used the evaluation version because I only needed it a handful of times.

    Below is an example of the output for a procedure after some configuration.

    IF (EXISTS(SELECT * FROM sys.objects WHERE [object_id] = OBJECT_ID(N'[dbo].[myProcedure]') AND [type]='P'))
    DROP PROCEDURE [dbo].[myProcedure]
    GO
    
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    GO
    
    CREATE PROCEDURE dbo.myProcedure
    AS
        select 1 as a
    GO
    

提交回复
热议问题