Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect syntax near 'ge'. [SQLSTATE 42000]

Author  Topic 

salimsql
Starting Member

5 Posts

Posted - 2006-06-16 : 02:44:25
Msg 102, Sev 15, State 1, Line 134 : Incorrect syntax near 'ge'. [SQLSTATE 42000]



hi

I have a script which worked fine in SQL SERVER 2000. We have now upgraded to SQL SERVER 2005 (SP1). When I run the script from Query Analyser it works fine. But when I schedule the same script to run as a job, it fails and i get the following error:

Msg 102, Sev 15, State 1, Line 134 : Incorrect syntax near 'ge'. [SQLSTATE 42000]

Now, there is no problem with the syntax.
What could be the problem?? I have been searching for a logical answer on the Internet and although other people seem to have encontered a similar problem, I have yet to find an answer.

Million thanks if u can help.

Thanks
John

psawant
Starting Member

14 Posts

Posted - 2006-06-16 : 03:11:51
Just look if you missed any variable or some declare part of your query?

Are you running this query as t-sql or from file in job?

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-16 : 03:29:22
quote:
Originally posted by salimsql

Msg 102, Sev 15, State 1, Line 134 : Incorrect syntax near 'ge'. [SQLSTATE 42000]
Post sp here. Something is going wrong at line 134 in your sp. Is the query a dynamically built query with 134 rows?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-06-16 : 03:37:02
tell us if that query is dynamic or static..?
this is mostly for Syntax error or access violation
see the permission and owner also for that table and sp also
Go to Top of Page

salimsql
Starting Member

5 Posts

Posted - 2006-06-16 : 07:42:24
hi
part of the query (entirely T-SQL) is dynamic (but not all). The dynamic part spans over 233 lines. That is, I have put an SQL statement in a string variable (@SQLString) and then I execute it thus:

EXEC (@SQLString)

The whole query (non-dynamic part and all) works perfect in Studio (SQL Server 2005). But if I take the same query and paste in in the Command box for step 1 of job1 and then start job1, I get the error.
Go to Top of Page

salimsql
Starting Member

5 Posts

Posted - 2006-06-16 : 07:57:48
even if i run the non-dynamic part in a seperate job, i still get a similar error
Go to Top of Page

psawant
Starting Member

14 Posts

Posted - 2006-06-16 : 08:26:52
Are you using any cursor in your query?
How are you building your query is it a static or build’s on different condition's?



------------------------
Prakash Sawant
http://psawant.blogspot.com
Go to Top of Page

salimsql
Starting Member

5 Posts

Posted - 2006-06-16 : 09:08:54
no cursor. A lot of conditions.
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-06-16 : 09:32:13
My guess, your dynamically built query is being preemptively cut off because the variable holding it is too short.

try doing a PRINT of the query instead of executing it.

-------
Moo. :)
Go to Top of Page

salimsql
Starting Member

5 Posts

Posted - 2006-06-19 : 02:24:34
hi

Unfortunately, if I take only the static part (no dynamic code included) and run it as a job, I still get the problem.
Go to Top of Page

pradeepmm
Starting Member

1 Post

Posted - 2007-06-20 : 12:36:17
Hi Salim,

I am not sure if you have your problem fixed. I had a similar issue.

On looking around the answers and working it out. Check for the following possiblities

1. Check for the (lines of code)loc on the sql script.
2. SQL JOB does not execute scripts that are more that 800 loc.



Pradeep MM
Ph: Off: (080) 634 9878/81 Extn: 23
Res: 343 4654
Go to Top of Page

mrmankge
Starting Member

1 Post

Posted - 2012-04-03 : 09:15:29
I had the same problem and After a long struggle and research, I found out that I had to put in each of my execute @sSQL in the brackets like

before - execute @sSQL
after - execute (@sSQL)
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-04-03 : 09:34:24
I find that when i resurrect 5 year old threads, i piss off a lot of people...









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -