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
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 query works with osql but not with sqlcmd

Author  Topic 

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-04-06 : 01:07:54
One of my query is giving me some hard time...can anyone help me out here...

When i run the below script...
osql -U -P -S -ic:\2.sql -oc:\2.log

it works like a champ...

but when i run the below script..
sqlcmd -U -P -S -ic:\2.sql -oc:\2.log

it throws me an error saying Incorrect syntax near go msg 102.
Any ideas of why this is behaving in this way?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-04-06 : 04:06:07
The error comes out of the script named 2.sql.
We need to see it...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-04-06 : 11:53:10
Yeah, it is coming from 2.log. but the same query was running OK with osql. The problem arises only when i run with sqlcmd.

The query is huge, i will try to modify it little bit and post it here.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-06 : 12:14:32
You probably have already done this, but since this seems like a parser error you could open the 2.sql file in SSMS and parse it (or even try to run it if that is possible). That will rule out syntax errors in 2.sql as being the source of the problem.

Go to Top of Page
   

- Advertisement -