Msg 102, level 15, State 1, Line 102

5 pts.
Tags:
SQL Server
SQL Server errors
Stored Procedures
I get this with an 'Incorrect syntax' messasge when I run a stored procedure. if I run the 'offending' code in isolation it works fine. If I tidy the code (e.g. remove line feeds etc), the error 'moves' to a different location. HELP!
ASKED: February 27, 2008  12:55 PM
UPDATED: January 22, 2010  6:08 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Are you running the code using Management Studio (SQL 2005) or Query Analyzer (SQL 2000)?

Sometimes the “compiler” cannot ubicate the exact place where the error appears.
You can create the SP in phases: each time place the “go” in a different place and see what are the parts that run successfully without returning the error, until you reach the problematic place.

It would help me help you if you could post the code of the Proc.

Regards,
Michelle.

When debugging SQL Procedures you need to remember to remove the white space above the ALTER PROCEDURE line when counting down the lines.

What happens if you run the entire procedure out side of the procedure. In order words comment out the ALTER PROCEDURE line and manually set any input parameters. Then when the error comes up you can double click on it to get to the offending line(s) of code.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    Check out my SQL Server blog "SQL Server with Mr Denny" for more SQL Server information.
    65,450 pointsBadges:
    report
  • Christian158
    "Msg 102, Level 15, State 1" Message I got this one when i run the re-buider index code from MS in "AdventureWorks2008. When i run it on the others AdventureWorks databases, no problem ! see the sql code : DECLARE tables_cursor CURSOR FOR SELECT s.name, t.name FROM sys.objects AS t JOIN sys.schemas AS s ON s.schema_id = t.schema_id WHERE t.type = 'U'; OPEN tables_cursor; DECLARE @schemaname sysname; DECLARE @tablename sysname; DECLARE @num int =0; FETCH NEXT FROM tables_cursor INTO @schemaname, @tablename; --WHILE (@num < 10) WHILE (@@FETCH_STATUS <> -1) BEGIN; EXECUTE ('ALTER INDEX ALL ON ' + @schemaname + '.' + @tablename + ' REBUILD;'); FETCH NEXT FROM tables_cursor INTO @schemaname, @tablename; SET @num = @num + 1 END; PRINT 'Nbre de tables RE-INDEXEES ' + convert(char(03),@num); PRINT 'The indexes on all tables have been rebuilt.'; CLOSE tables_cursor; DEALLOCATE tables_cursor;
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following