18 November,2014 by Tom Collins
Question: How can I read the script contents into the Powershell CommandText ?
Normally I place the query text with the Powershell CommandText , but on this occasion I want to read a large query from a sql file.
$sql.CommandText = "SELECT name from sys.sysdatabases”
Answer: Reading the contents from a script file is a good idea as it allows you to reuse your script library and maintain them in a script library.
$sqlCommand.CommandText = get-content c:\scripts\SQLText.sql
Powershell , Excel charts and data presentation
Powershell sql server security audit
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |