SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

syntax error in textheader of stored procedure - Cause and Solution

Hi Folks,

Comments play an important part in writing any code. Especially when somebody else reads your code. So the other day I was writing a stored procedure and some comments on top to list the tasks being performed inside the stored procedure. We are using sql server 2005 and the code snippet was something like this :-

/*abc
/*
/*
-----
----The logic of the stored procedure is ...

*/

*/
*/

alter proc abcd @i int
as
select 1

I was able to create the sp without any problems, however on clicking modify (when you try to see or edit the sp inside ssms) it gave me an error:-
syntax error in textheader of stored procedure

On further searching online I found that it has to do with embedded comments like the one as following :-

/*
/*
----*/
*/

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


If you notice above lines you ll see comments are being embedded inside parent /* -----*/ comments.  So I got rid of the internal comments like this

/*abc


-----
----The logic of the stored procedure is ...




*/

alter proc abcd @i int
as
select 1

and it saved my day.

I tried to simulate similar problem in SQL SERVER 2014, however could not do that. So I think it can only be found with SQL SERVER 2005 version.







EVERYDAY MSBI/SQL CHALLENGES

My name is Lokesh Sharma, I have 5 years of experience working with SQL and am really interested in exploring more and more about this fascinating language. My aim here is to share some of the challenges that I faced while working with SQL and also to get feedback whether the approach I followed is an optimal one or not.

Comments

Leave a comment on the original post [itchallengesdaily.blogspot.com, opens in a new window]

Loading comments...