SQL Query result in Octopus deployment log

Hey team,
I created a deployment step to run a T-SQL query using powershell. script. But In the deployment log I am not able to see the complete details. say for example, this is the query - select @@version, passed in the query… the result I am getting in the logs is incomplete -

Executing script on 'XXXXXXXXXXXX’
August 16th 2017 20:51:25Info
Column1
August 16th 2017 20:51:25Info

August 16th 2017 20:51:25Info
Microsoft SQL Server 2014 - 12.0.2000.8 (X64) …

I need the complete output of the SQL query result…

Hi, thanks for reaching out.

I assume you are running a command like Invoke-Sqlcmd in Powershell, is this correct?

If so you can control the details that are output by piping the result to format commands like Format-List or Format-Table. There is some documentation from Microsoft on these commands at https://docs.microsoft.com/en-au/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view?view=powershell-5.1

Regards
Matt C

Hi Matthew,

Thanks for your response… Yes, I am using invoke-command to execute the
SQL script using powershell…

I have a TSQL query to get the result in table format with columns as you
see below…

In the result row, the server name is getting trimmed and the full value is
not getting displayed.

can you help me to get a perfect table structure, because with respect to
this output, i need to perform the other steps in the deployment.

21:01:28 Info | server recoverymod database_na
Full_backu fullbackup Log_backup logbackupd
21:01:28 Info | e me p_type
duration _type uration
21:01:28 Info | ------ ----------- -----------


21:01:28 Info | USSECVMP… DEA_Test full
00:00:00
21:01:28 Info | USSECVMP… dummy_db full
00:00:05 log 00:00:00
21:01:28 Verbose | Updating manifest with output variables
21:01:28 Verbose | Updating manifest with action evaluated variables

Regards,
Krishna Kumar

Hi Krishna,

Does the Format-List output work for you? i.e.

Do-Something | Format-List

Otherwise you might be able to use the -autosize option with Format-Table. The docs at https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view?view=powershell-5.1#improving-format-table-output-autosize have some examples. Or the -Wrap option to ensure that Powershel does not truncate the data. The docs at https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view?view=powershell-5.1#wrapping-format-table-output-in-columns-wrap have an example of this option.

Regards
Matt C