SET QUOTED_IDENTIFIER ON

  • Hi all,

    When i write the comments above this statement they are not reflected, but when i write them below this statement they are saved along with SP.

    I read about SET QUOTED_IDENTIFIER ON but it never says anything about comment. Could anybody provide me with answer or link to read on.

  • When I script out a stored procedure in SSMS, the SET QUOTED_IDENTIFIER ON is placed above the Stored procedure declaration. So I'm wondering, are you sure you're including the comments within the body of the sproc?

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Abu Dina (12/21/2012)


    When I script out a stored procedure in SSMS, the SET QUOTED_IDENTIFIER ON is placed above the Stored procedure declaration. So I'm wondering, are you sure you're including the comments within the body of the sproc?

    I wrote as /*

    This is just the demo

    */

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE PROCEDURE dbo.Demo3

    AS

    BEGIN

    SELECT * FROM dbo.emp

    END

    GO

    Then i run the SP.When i click on modify button of SP it shows me

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[Demo3]

    AS

    BEGIN

    SELECT * FROM dbo.emp

    END

  • Then that's normal application behaviour I'm afraid.

    If you want SQL Server to retain your comments within the stored procedure then you need to include the comments within the body of the sproc. Comments outside only get saved if you save the actual .sql file.

    See below:

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Abu Dina (12/21/2012)


    Then that's normal application behaviour I'm afraid.

    If you want SQL Server to retain your comments within the stored procedure then you need to include the comments within the body of the sproc. Comments outside only get saved if you save the actual .sql file.

    No, that is not true.

    try:

    /*comments*/

    CREATE PROC dbo.p_Test AS

    SELECT 1

    GO

    Comments can precede CREATE/ALTER line.

    It is most common practice to have stored procedure header comments section outside of stored proc body.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • You're right.. I take that back :blush:

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Comments can precede CREATE/ALTER line.

    It is most common practice to have stored procedure header comments section outside of stored proc body.

    While true, that's being a bit picky:-) Comments immediately preceding CREATE/ALTER do attach themselves to the procedure definition, but nothing else does - nothing that actually does anything.

    And as to common practice - not in my experience. I guess it depends on whatever standards are in place where you are working.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Shadab Shah (12/21/2012)


    Abu Dina (12/21/2012)


    When I script out a stored procedure in SSMS, the SET QUOTED_IDENTIFIER ON is placed above the Stored procedure declaration. So I'm wondering, are you sure you're including the comments within the body of the sproc?

    I wrote as /*

    This is just the demo

    */

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE PROCEDURE dbo.Demo3

    AS

    BEGIN

    SELECT * FROM dbo.emp

    END

    GO

    Then i run the SP.When i click on modify button of SP it shows me

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[Demo3]

    AS

    BEGIN

    SELECT * FROM dbo.emp

    END

    Note that your comment and your procedure declaration are separated by a "GO". They are sent and executed as different batches by SQL server.

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • Phil Parkin (12/21/2012)


    ...

    And as to common practice - not in my experience. I guess it depends on whatever standards are in place where you are working.

    In SSMS Object Explorer, go into any database/Programmability/Stored Procedures.

    Right-click on Stored Procedures and select "New Stored Procedure..."

    You will see that is part of standard template...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Eugene Elutin (12/21/2012)


    Phil Parkin (12/21/2012)


    ...

    And as to common practice - not in my experience. I guess it depends on whatever standards are in place where you are working.

    In SSMS Object Explorer, go into any database/Programmability/Stored Procedures.

    Right-click on Stored Procedures and select "New Stored Procedure..."

    You will see that is part of standard template...

    Blimey! As you might have guessed, I don't create procs like that:-)

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Phil Parkin (12/21/2012)


    Eugene Elutin (12/21/2012)


    Phil Parkin (12/21/2012)


    ...

    And as to common practice - not in my experience. I guess it depends on whatever standards are in place where you are working.

    In SSMS Object Explorer, go into any database/Programmability/Stored Procedures.

    Right-click on Stored Procedures and select "New Stored Procedure..."

    You will see that is part of standard template...

    Blimey! As you might have guessed, I don't create procs like that:-)

    Me too, but that might be what makes it to be "common practice" 😉

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

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

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