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 2000 Forums
 SQL Server Development (2000)
 Running a .sql file via BCP

Author  Topic 

pug2694328
Posting Yak Master

166 Posts

Posted - 2006-02-17 : 15:27:43
Is there a way to run queries saved in an .sql file via the Bulk Copy Program?

I've used it to run queries embedded in the BCP command and also to run PROCs, but am wondering if I can save a buncha queries to files and hit them with a command line driven program.

I've never used OSQL, but maybe that would be a way to get it done.

Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-17 : 15:41:24
Not with bcp.exe, but you can with osql.exe. Here is an example:

osql.exe -SServer1 -E -iC:\SomeFile.sql -oC:\SomeOutputFile.txt

Tara Kizer
aka tduggan
Go to Top of Page

pug2694328
Posting Yak Master

166 Posts

Posted - 2006-02-21 : 11:30:35
Excellent, thanks works like a charm!
Go to Top of Page
   

- Advertisement -