June 3, 2015 at 3:35 pm
When I execute the following command, I get the output truncated to 79 characters, including three dots (as an ellipsis, I suppose).
EXEC master..xp_cmdshell 'powershell.exe "Get-ChildItem D:\Databaze\paleontologie\prilohy\verejne\g -filter g417*.* -recurse | select Fullname | out-string -width 255"'
When I execute the core command directly in Powershell, whether the text or ISE version, it works correctly, with or without the out-string -width command.
Get-ChildItem D:\Databaze\paleontologie\prilohy\verejne\g -filter g417*.* -recurse | select Fullname | out-string -width 255
What does it take to get SSMS to not truncate my output strings?
June 3, 2015 at 3:48 pm
One option would be to send the results to file. I know I'd like a better option, but it's better than nothing.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
June 3, 2015 at 3:57 pm
Alvin Ramard (6/3/2015)
One option would be to send the results to file. I know I'd like a better option, but it's better than nothing.
I'd like to keep it in memory, if possible, but thank you for the idea.
June 3, 2015 at 4:39 pm
Interesting. A similar script behaves the same (truncated results) for me both when run from Powershell and from xp_cmdshell.
I'm not sure how you're intending to use it, so this might not work, but you could use Format-Table -Wrap instead of Out-String. That's slower, but it at least doesn't truncate.
Alternatively, it might be something to do with how that select Fullname is processed. When I replace select Fullname with foreach-object {$_.Fullname}, I avoid truncation.
The Powershell force is not strong with me, so these ideas may not help much. Hopefully they do, though.
Cheers!
June 3, 2015 at 10:25 pm
IIRC, the old "mode" command for DOS will do it for you. See the following.
EXEC master..xp_cmdshell 'mode con cols=255 && powershell.exe "Get-ChildItem D:\Databaze\paleontologie\prilohy\verejne\g -filter g417*.* -recurse | select Fullname | out-string -width 255"'
--Jeff Moden
Change is inevitable... Change for the better is not.
June 3, 2015 at 11:29 pm
Mode con works, Format-Table -wrap still truncates. Thank you both.
June 4, 2015 at 8:54 am
pdanes (6/3/2015)
Mode con works, Format-Table -wrap still truncates. Thank you both.
You bet. Thanks for the feedback.
What I don't like about PoSh output is that it will vary the width of columns based on the data being output to try and conserve horizontal space. There are ways around that but they all seem to be overly complicated.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply