I am trying to run multiple SQLCMD statements (that archive tables in SQL Server 2008 and create restore scripts) from windows .bat file. My scripts work like first I perform SQL Authentication and then I input SQL scripts to output restore files
sqlcmd -S <Server name>\<instance> -U user
sqlcmd -i ArchiveTable1.sql -o RestoreTable1.sql
sqlcmd -i ArchiveTable2.sql -o RestoreTable2.sql
sqlcmd -i ArchiveTable3.sql -o RestoreTable3.sql
Problem is that after sqlcmd authentication, there appears prompt 1> and does not execute my next statements. On entering Quit, my next statements get executed but in output files I see authentication invalid error. I dont want to have sql authentication with each sqlcmd statement.
If there is issue with my approach, can somebody guide me to use other design.