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
 Other SQL Server 2008 Topics
 batch file to run sql query

Author  Topic 

paulsparrow
Starting Member

1 Post

Posted - 2009-09-14 : 20:00:59
I am trying to find out what to write in a batch file to run a sql query stored locally. IE open sql server management studio and run my sql code.

This would be a batch file activiated by windows scheduler locally. I use to do this with SAS but I have to work with SQL Server now so any help would be great.

Thanks

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-15 : 04:36:14
Lookup SQLCMD in BOL or MSDN: http://msdn.microsoft.com/en-us/library/ms162773.aspx

You can then save the sqlcmd calls in a batch file (e.g. c:\scripts\sqlDaily.bat). And schedule this in windows scheduler on your local machine, as requested.

I'd advise that you run any job on a server instead of client machine.

Go to Top of Page
   

- Advertisement -