-1

I need to write a batch script that calls a SQL Server query and runs a procedure in a SQL Server database and stores the result log in a file.

threxx
  • 1,213
  • 1
  • 31
  • 59
ankit
  • 1

1 Answers1

1

You can create a .bat file with contents like this:

cd %0\..
  sqlcmd -S YourServerName -d "YourdatabaseName" -U SqlLonginuserName -P Password -o "C:\Script_Output.txt" -p 1 -i "c:\LocationOfSQLScript.sql"
JBdev
  • 353
  • 1
  • 10