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
 SQLCMD

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 16:32:56
Hi i need to exec a sql command on a server without SQL. this will exec a insert statement on a remote sql server. i found SSEUtil.exe but the sytax is not working, is there a way to install the SQLCMD on it own without installing the whole SQL server install?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-24 : 16:37:14
What's the error?

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

Subscribe to my blog
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-24 : 16:40:10
I think you just need to install the sql sever native client.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 17:10:28
Ok yes i installed sql native client and then the SQLCMD. when i try and run the code below i get SQLCMD is not recongnized

sqlcmd.exe -S serverIpAddress -U username -P password -d database -Q "insert into SimCardReceived (NumberFrom, Message, SimNumber) values ('_FROM_','_BODY_','03')"

any ideas?
Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 17:28:20
if i do

cd "C:\Program Files\Microsoft SQL Server\100\Tools\Binn"

and then run the script it works fine, how can i add this to 1 line of code i have tried a few variations but cant get it to work
Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 17:33:49
ok sorted it thanks
Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 17:57:12
I still have a problem, i can run the code below in cmd and it works fine, i have a windows appliaction which execs this code this stripps out the quotes around the path so it causes an error. is there a way to map "sqlcmd" so windows knows the path. so i can just run

this

sqlcmd.exe -S ipaddress -U username -P pass -d atabase -Q "insert into SimCardReceived (NumberFrom, Message, SimNumber) values ('_FROM_','_BODY_','02')"

instead of this

"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -S ipaddress -U username -P pass -d atabase -Q "insert into SimCardReceived (NumberFrom, Message, SimNumber) values ('_FROM_','_BODY_','02')"

Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-24 : 18:22:37
You could try to add C:\Program Files\Microsoft SQL Server\100\Tools\Binn to the system path variable. Here is a description of how to do that in Windows 7. http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-04-24 : 18:51:13
No that didnt work, i am using window server 2003, i updated the path restarted the server and typing sqlcmd into run did not work, any other ideas how i can do this?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-24 : 19:14:37
Check the path variable. Type path in a cmd window and see if that path is in there. If it's not, then you didn't add that path to the environmental variable correctly.

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

Subscribe to my blog
Go to Top of Page
   

- Advertisement -