mssql-cmd - SQL Server interactive and batch query command-line tool »

Download mssql-cmd Free Trial »

Run sql scripts from command or file

Run scripts from command

example:

mssql-cmd > select * from media_messages;


Run scripts from file

In interactive mode:

mssql-cmd>source #sqlfile#;

example:

mssql-cmd > source e:\temp\tables\insert_data.sql


In batch mode:

mssql-cmd dsn="username:password@host:port/dbname" task=source sqlfile=#sqlfile#

example:

mssql-cmd dsn="pan:withdata@192.168.0.102::1433/test" task=source sqlfile=e:\temp\tables\insert_data.sql