Hello
I am trying to use sqlcmd to run a set of sql statements. If I use -i switch and input a file with sql statements, it is working fine, but I am trying to use the sql statements using -q to avoid the creation of the input file. But I am not having luck with -q, can someone let me know if putting multiple lines of code is possible in -q switch like below?
A simple restore command like below. If I use the whole restore command in single line it works fine like below:
sqlcmd -E -S servername -d master -Q "restore database bestst_test from disk='E:\Backup\test\bestst\bestst_20101222.bak' with move 'BESMgmt415_data' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test.mdf',move 'BESMgmt415_log' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test_log.ldf' "
but if I split the restore command into 3 lines like below, it fails, can someone let me know how to use the multiple line feature in sqlcmd -q switch?
sqlcmd -E -S servername -d master -Q "restore database bestst_test from disk='E:\Backup\test\bestst\bestst_20101222.bak'with move 'BESMgmt415_data' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test.mdf',
move 'BESMgmt415_log' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test_log.ldf' "