SQL Server provides us convenient way to import large data from .sql file using sqlcmd tools. Sometimes we need to import data using .sql file when SQL Server version is different between source and target database.
Let’s say the file is named import_db.sql, produced by ‘Generate Scripts’ feature in SQL Server Management Studio.
Import import_db.sql to destined database is very simple using sqlcmd tools.
- open windows command prompt
- write sqlcmd -E -i import_db.sql
- wait until sqlcmd finished execute the whole file
However, there is limitation using this method. Database name in ‘source database’ must be the same with database name in ‘target database’. Anyway we could handle this by manually edit import_db.sql.