Running Microsoft SQL Server SQL scripts with sqlcmd.exe from the command line

I needed to import a large amount of data in the form of a .sql script file, auto generated elsewhere, into my SQL Server 2005 Express database. The command was run on the localhost of the database and is actually really easy. sqlcmd.exe needs to be in your PATH and it is by default when you install SQL Server. I was also running this as an administrator with database permissions, although you can enter specific permissions manually if you need to:

sqlcmd -S SERVERNAMESQLEXPRESS -d DatabaseName -i c:scriptname.sql

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>