title: How to provide output Parameter SqlProcedure in powerShell
body: <p>Hi I have Procedure with following definition</p>
  <pre><code>PROCEDURE [dbo].[import_copy_table_to_backup]
      @source_tablename nvarchar(max),
      @target_tablename nvarchar(max),
      @source_filename nvarchar(max),
      @rows   bigint OUTPUT
      
  AS Begin
  </code></pre>
  <p>And I am getting following exception
  Exception calling &quot;Fill&quot; with &quot;1&quot; argument(s): &quot;Procedure or function 'import_copy_table_to_backup' expects parameter
  '@rows', which was not supplied.&quot;
  At E:\PowerShell-Scripts\fetchDataFiles.ps1:233 char:3</p>
  <p>Below is my code</p>
  <pre><code>$SqlQuery = &quot;exec import_copy_table_to_backup '$tableName', 'import_abcd_data', '$fileFullName' &quot;
          $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
          $SqlConnection.ConnectionString = &quot;Server = $SQLServer; Database = $SQLDBName; User ID = $uid; Password = $pwd;&quot;
          $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
          $SqlCmd.CommandText = $SqlQuery
          $SqlCmd.Connection = $SqlConnection
          
          $outParameter = New-Object System.Data.SqlClient.SqlParameter
          $outParameter.ParameterName = &quot;@rows&quot;
          $outParameter.Direction = [System.Data.ParameterDirection]::Output
          $outParameter.DbType = [System.Data.DbType]::Int64
          
          $SqlCmd.Parameters.Add($outParameter) | Out-Null
          
          $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
          $SqlAdapter.SelectCommand = $SqlCmd 
          $DataSet = New-Object System.Data.DataSet
          $SqlAdapter.Fill($DataSet)
          $SqlConnection.Close()
  </code></pre>
  <p>I am new to both Powershell &amp; Sql Procedures. Ask here is to know the correct way to supply the output Parameter.</p>
  <p>Thanks Much!</p>