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
 insert via command line

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2009-05-08 : 10:13:54
hi i have a desktop app, which has a option to call the cmd, this desktop app reveives data, i just need to do a simple insert into a sql server 2008 table, but i am not sure how to do this via a command prompt, i have thsi line

echo insert into smstable values(curtime(), '_FROM_','_BODY_'); | "c:\Program Files\mysql5.0.51b\mysql" smsbase

which is for mysql i just need to know how to do the same for sql server

CAN SOMEONE PLEASE HELP

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-08 : 14:19:07
You can use sqlcmd.exe to run queries from the command line. Run sqlcmd /? from a cmd window to see its options. You can choose to either provide a script file with the queries by using the i switch, or maybe you want to do it interactively in which case just provide -S and then either -E or -U/-P.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -