1

I need to create a batch file (script) to copy entire content of one SQL Server database to another. Source database is local for the machine. What command line tools and commands therein I could use? Destination database can be dropped entirely.

Also, I need to run a pair of SQL queries afterwards, also from batch file.

Thanks in advance!

2 Answers 2

1

you can read about Run Transact-SQL Script Files Using sqlcmd from here: http://msdn.microsoft.com/en-us/library/ms170572.aspx

Sign up to request clarification or add additional context in comments.

Comments

1

first u need to create your sql queries then u can use this command to run it via batch file

sqlcmd -S %computername%\%SName% -U %UName% -P %Pwd%  -i SQL_DB.sql >> _Deploy.txt 2>&1

this command gets computer name and sqlserver instance name and user name and password and run SQL_DB.sql file near batch file that contains our queries and save the result in a text file named _deploy.txt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.