Wednesday, October 9, 2013

Using command line to import a large SQL file into SQL Server Express 2008

Suppose you have a large SQL file (file with extension *.sql) that you want to import into a database in SQL Server Express 2008. you can use the following command line:

sqlcmd -S [ServerName]\[ServerInstanceName] S -d [DatabaseName] -i [SQLFilePath]

For example, suppose the SQL file is located at D\temp\mixertruck.sql, and you use default server instance .\SQLEXPRESS which already has a database mixertruck, then the command line is as follows:

sqlcmd -S .\SQLEXPRESS -d mixertruck -i D:\temp\mixertruck.sql

No comments:

Post a Comment