Powershell v3 - SQLCMD

sj77
sj77 used Ask the Experts™
on
I need to build a PS script that will call upon the MSSQL db and pass through a t-sql query to backup a database, then, restore the backup into another DB on the same server.

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Engineer
Distinguished Expert 2017
Commented:
If you perform a search in the internet you'll find some examples for Backup & Restore SQL Server databases with powershell even I thing this will be more easily done with SQLCMD.
May I know why do you need this to be done with powershell?

Author

Commented:
I just recently started getting into powershell, and, I love the power it brings to the table. So I was curious to a backup example in powershell for SQL DB.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
Ok but for SQL Server whenever you can, use proprietary scripts.
Check the link I've posted in my last comment to see if it helps you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial