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
 OSQL script to SQLCMD script

Author  Topic 

lostgolfballs
Starting Member

5 Posts

Posted - 2012-10-08 : 16:32:08
Hi,

We have an old OSQL script that is not working on the computers. I did some research and found out the command will work if it's converted to SQLCMD.

Since I'm not a SQL programmer, how can i convert the OSQL to SQLCMD script?

The original command line is

osql -Q "USE (DB Name) EXEC sp_importFedExData" -S(Db Path) -Usa -P(DB name)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-10-08 : 16:34:58
Can't you just replace osql with sqlcmd?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

lostgolfballs
Starting Member

5 Posts

Posted - 2012-10-08 : 16:49:45
I tried and it came out with bunch of errors like
"an unexpected end of file was encountered in the data file."
"msg 7399, level 16, state 1, server (DB name) line 1"


quote:
Originally posted by tkizer

Can't you just replace osql with sqlcmd?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-10-08 : 16:51:54
sqlcmd -Q "EXEC DbName.dbo.sp_importFedExData" -Sserver1 -Usa -Ppassword

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

lostgolfballs
Starting Member

5 Posts

Posted - 2012-10-09 : 09:27:13
I ran the command and it cambe back.
msg2812, level 16, state 62, server (server name), line 1
could not find the stored procedure '(dbname.dbo)'


quote:
Originally posted by tkizer

sqlcmd -Q "EXEC DbName.dbo.sp_importFedExData" -Sserver1 -Usa -Ppassword

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-10-09 : 11:47:52
I would go first to SQL server Query Analyzer and run that sp. if it succeed than you will be looking at changing your parameters of isql/osql/sqlcmd.

Also, look at what version of MS SQLserver you are running because that could be a cause too.

--------------------------
Joins are what RDBMS's do for a living
Go to Top of Page

lostgolfballs
Starting Member

5 Posts

Posted - 2012-10-09 : 12:05:55
quote:
Originally posted by xhostx

I would go first to SQL server Query Analyzer and run that sp. if it succeed than you will be looking at changing your parameters of isql/osql/sqlcmd.

Also, look at what version of MS SQLserver you are running because that could be a cause too.

--------------------------
Joins are what RDBMS's do for a living

Go to Top of Page

lostgolfballs
Starting Member

5 Posts

Posted - 2012-10-09 : 12:07:09
accident on the last post...
this is what i got from the analyzer.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'Q'.


quote:
Originally posted by lostgolfballs

quote:
Originally posted by xhostx

I would go first to SQL server Query Analyzer and run that sp. if it succeed than you will be looking at changing your parameters of isql/osql/sqlcmd.

Also, look at what version of MS SQLserver you are running because that could be a cause too.

--------------------------
Joins are what RDBMS's do for a living



Go to Top of Page

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-10-09 : 13:43:27
you only need to execute the following on SQL analyzer:
"USE (DB Name) EXEC sp_importFedExData


--------------------------
Joins are what RDBMS's do for a living
Go to Top of Page
   

- Advertisement -