August 13, 2008 at 5:22 pm
I like to create same database and tables in different Sql Server (around 50). I don't want to do this task manually. Please advise me how to do this task by script or SQLcmd? Thanks in advance.
August 13, 2008 at 9:31 pm
Using SSMS you can script out all objects in a database. Right-click on the database, select Tasks then Generate Scripts. Set your options to include database creation and whatever else (like indexes, triggers etc). Save it to a file.
Then run sqlcmd and use the following parameters:
-S servername
-E or
-U and -P credentials with sysadmin rights
-i path + name of file you created above
Make sure the path that the database files get created in exists on the other server first. Otherwise, edit the file and set the path to what it needs to be.
MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare
August 14, 2008 at 9:50 am
Thanks a lot. It helps lot for me.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply