SSMS Question about Templates

  • Does anyone know of a way to modify the Templates that are used in the "Script <object> as" submenu? (when you right click an object in object explorer, then go into the "Script <insert object> as")

  • See this link: http://msdn.microsoft.com/en-us/library/ms174169.aspx

    Thanks,

    Jared

    Jared
    CE - Microsoft

  • Jared you're the man!

  • actually no luck. even when i change the template it still just encapsulates the SP in sp_executesql

    USE [DB]

    GO

    /****** Object: StoredProcedure [dbo].[proc] Script Date: 09/15/2011 11:04:18 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[proc]') AND type in (N'P', N'PC'))

    BEGIN

    EXEC dbo.sp_executesql @statement = N'

    ALTER PROCEDURE [dbo].[proc]

    AS

    BEGIN

    ....

    END

    '

    END

    GO

    I don't know what happened but suddenly it changed to this format, and can't get it to return to the way it was, even after I edit the templates Jared pointed out

  • Hmm... What exactly did you do? Did you edit an existing template file or did you create a custom one?

    Jared

    Jared
    CE - Microsoft

  • I'm 85% sure you guys are not talking about the same template concept.

    1 talks about scripting and the other one talks about user made scripts you can edit with parameters (like in the link).

    I don't know if / how to do the former.

  • Ninja's_RGR'us (9/15/2011)


    I'm 85% sure you guys are not talking about the same template concept.

    1 talks about scripting and the other one talks about user made scripts you can edit with parameters (like in the link).

    I don't know if / how to do the former.

    I believe Ninja is correct.

  • I see... Maybe this will help you: http://www.karaszi.com/SQLServer/info_generate_script.asp

    Thanks,

    Jared

    Jared
    CE - Microsoft

  • If anyone cares, I found out the problem.

    SSMS Menu -> Tools -> Options

    In the left window click on the SQL Server Object Explorer branch > Scripting

    In the list on the right, under Object scripting options set the choice for "Include IF NOT EXISTS clause" to false

  • Gabriel P (9/21/2011)


    If anyone cares, I found out the problem.

    SSMS Menu -> Tools -> Options

    In the left window click on the SQL Server Object Explorer branch > Scripting

    In the list on the right, under Object scripting options set the choice for "Include IF NOT EXISTS clause" to false

    Great! Thanks for posting the solution 🙂

    Jared

    Jared
    CE - Microsoft

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply