October 31, 2007 at 7:20 am
Does anyone know how to get a sql script to run from the cmd line... What i mean by this is that I can type something into the cmd line so that it reaches out and starts the script
October 31, 2007 at 8:04 am
October 31, 2007 at 8:16 am
that really doesnt help me that much... i need to run a command line that will start a query... i have it saved on the c drive of the sql server.
October 31, 2007 at 8:31 am
Ok, I'm not sure I understand your question. If your attempting to execute a SQL script from the command line, you can use SQLCmd (i.e. calling SQLCmd directly, from a batch file, vbscript, etc.)
sqlcmd -S
-or-
sqlcmd -Q "SELECT * FROM AdventureWorks.Person.Contact" -o MyOutput.txt
Tommy
Follow @sqlscribeOctober 31, 2007 at 9:11 am
ok here is the query that i have
use "washco redtitan"
Bulk Insert test2
FROM 'C:\Documents and Settings\test\Desktop\WashingtonXMLScriptssample\washco911.csv'
WITH
(
FirstRow=2,
FIELDTERMINATOR = '","',
ROWTERMINATOR = ''
)
UPDATE dbo.test2 SET Program = REPLACE(Program, '"', '' )
update dbo.test2 SET FileName=Replace(FileName, '"','')
We have a program that creates print files and stores them in a folder. What i need to do is pull the file into sql. The program we are using allows you to create rules or actions when a file is opened. So what I am responsible for is creating something that will pull the data into the sql database. So I wrote this query, and what I need to do is use cmd like to execute this these statements.
October 31, 2007 at 9:57 am
This sound like a good candiate for SSIS. SQLIS has some good examples, ie.
What I was suggesting earlier is that you save this query as BLAH.sql and use SQLCmd to execute it. i.e.
sqlcmd -S MyServer -i C:\MyScript.sql
SSIS would be a better choice for you given your requirements.
Tommy
Follow @sqlscribeViewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy