December 21, 2012 at 6:59 am
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.
December 21, 2012 at 7:01 am
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
December 21, 2012 at 7:05 am
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
December 21, 2012 at 7:20 am
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
December 21, 2012 at 7:53 am
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.
December 21, 2012 at 8:02 am
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
December 21, 2012 at 8:24 am
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
December 21, 2012 at 8:25 am
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.
December 21, 2012 at 8:29 am
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...
December 21, 2012 at 10:24 am
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
December 21, 2012 at 11:19 am
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" 😉
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply