0

I would like to get output from a SQL Server 2014 query without the header row (or the row with dashes -----). I'm running the queries from PowerShell using the invoke-sqlcmd cmdlet. Either suppress it in SQL Server, or Powershell is fine with me.

I know that if it's only 1 column, I can

invoke-sqlcmd {command here}).column_name

But I can't figure out how to suppress the headers if I need multiple columns returned.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
boblewis
  • 83
  • 8
  • In SSMS there is an option under Tools/Options/Query Results/SQL Server/Results to Text to disable header. In powershell there was /h -1 option to disable the headers. – Bodul Apr 13 '20 at 20:02
  • " In powershell there was /h -1 option to disable the headers" I've seen this before posting the question, but couldn't get it to work. Do you have an example? Maybe I'm just using it wrong. Also, I should have clearer in my post. Since, i'm running the powershell command, I can't set the SSMS option. – boblewis Apr 13 '20 at 20:08
  • Check https://learn.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15 Try with sqlcmd -q -h-1 if sqlcmd -q /h-1 does not work. – Bodul Apr 13 '20 at 20:14
  • Maybe I'm wrong, but I think the sqlcmd utility is different then invoke-sqlcmd from powershell, because all of these options return an error – boblewis Apr 13 '20 at 20:20
  • Yeah sorry. It is. There are some answers here on SO that are talking about that, maybe some of those can help you. https://stackoverflow.com/questions/43047946/invoke-sqlcmd-output-without-quotes-and-headers – Bodul Apr 13 '20 at 20:30

0 Answers0