0

I have a an sql script that creates a database, and want to know how to run this from a batch file at a command prompt. Do i create a batch file with a few lines of code pointing to the location of the .sql file, or create a new batch file containing the contents of the .sql file?

I've had a look at a couple of related questions, but can't seem to see a clear answer.

Thanks :)

user3722957
  • 87
  • 2
  • 8

2 Answers2

0

You could create a batch file and use the -i flag with sqlcmd.exe, where -i sets the path to the .sql file you want to run:

sqlcmd.exe -i F:\wherever\the\file\is

See http://msdn.microsoft.com/en-us/library/ms162773.aspx for a full list of the flags and this post, How to use sqlcmd to create a database.

Community
  • 1
  • 1
Snake_Plissken
  • 390
  • 1
  • 4
  • 14
0

is quite easy, you only need 3 things:

SQL Client Path/ Script Path/ SQL Conection data/

Then you can run it directly from the batch without any complex script - let me know if you have the info I can arrange it.

regards

Rokrman22
  • 15
  • 1
  • 1
  • 7