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
 How to execute a SQL-Script on SQL-Server 2005

Author  Topic 

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-02-15 : 16:35:41
I would like to know how to execute an existing sql-script (from a file) on a sql-server 2005 Express. I use SQL Manager 2005, but I do not want to use this tool - because parts of the script might not be executed in a transaction, so that I may not use SQL Manager 2005.
But anyway I would like to be able to execute this on commmand line. The problem is that I even do not know 1) how to start command line 2) how to execute the existing sql-file from there.

I would be very happy if anybody could help me out with this!

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 16:36:38
sqlcmd is the command line tool to use. It's the replacement for osql.exe. Check out sqlcmd from the command line passing it /? switch to see its options. You can also check out the help documentation to learn more about sqlcmd.

Tara Kizer
aka tduggan
Go to Top of Page

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-02-15 : 17:02:25
Hi Tara !

Thank you very much - that's what I needed !

by the way - this is how I executed the sql-script :

C:\>sqlcmd -S .\SQLExpress -i C:\test1.sql -o C:\MyOutput.txt

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !
Go to Top of Page
   

- Advertisement -