Hi,I'm new to using PowerShell to process a SQL Query. The query that I'm trying to process is from the Project Server ProjectWebApp database. I came across the following code that seems well structured and runs my SQL Query just fine:[code="sql"]#Read Projects From the ProjectWebApp Database, based on the SQL Query selection$SqlConnection = New-Object System.Data.SqlClient.SqlConnection$SqlConnection.ConnectionString = “Server=DBServerName;Database=ProjectWebApp;Integrated Security=True”$SqlCmd = New-Object System.Data.SqlClient.SqlCommand$SqlCmd.CommandText = $SqlQuery$SqlCmd.Connection = $SqlConnection$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter$SqlAdapter.SelectCommand = $SqlCmd$TargetDataSet = New-Object System.Data.DataSet$SqlAdapter.Fill($TargetDataSet)$SqlConnection.Close()[/code]The SQL Query in the $SqlQuery variable works perfectly, when I run this script and provides me with the Dataset needed in $TargetDataSet.However, I would like to use the SQL Switch -h-1 which I understand would suppress the inclusion of the Column Header and the line of dashes below the header, which currently is included in the dataset output.Does anyone know the syntax that would allow me to run this SQL Query with the column header suppression switch (-h-1)?Alternatively, is there another way to structure the code so that I can run this switch to suppress the headers?My dataset only returns a single column of values, but I need it to be without the headers. I attempted to remove the header in the SQL Query, but everything I tried there was unsuccessful. So if anyone knows how to remove headers using a SQL Query, I guess that would be helpful as well.Cheers,Wayne
↧