Using PowerShell for SQL Server Admin

PowerShell for SQL Server

Invokde-Sqlcmd cmdlet

You can use theĀ Invokde-Sqlcmd cmdlet to execute any T-SQL query:

For example to execute the sproc production.get_products_to_reorder on the Adverture Works 2008 database:

invoke-sqlcmd -query "exec production.get_products_to_reorder" -database adventureworks2008 -serverinstance localhost\sql2008

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>