Sep 172010
I had to write a script that ran a SQL SP this week and found that this was not the most straight forward thing to do.
This was how I managed do it.

    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "UID=”DBUID”;PWD=”password”;Server=”IP”;Database=”DB”;Integrated Security=False"
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = "sp_name"
    $SqlCmd.Connection = $SqlConnection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet) | Out-Null

All you Powershell gurus are more than welcome to suggest a better way…..

Post to Twitter

 Leave a Reply

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=""> <s> <strike> <strong>



10 + five =

Twitter links powered by Tweet This v1.8.3, a WordPress plugin for Twitter.