Reputation: 29159
For the following code
$sql = "select ..... for xml path('row')" # returns a long xml file
$x = Invoke-SqlCmd -Server xxxx $sql
$r = $x[0].ItemArray[0]
The returned $r
has a truncated xml string. How to make sure the full long string is returned?
Upvotes: 21
Views: 14319
Reputation: 9126
That cmdlet has a default max character length, defaults to 4,000 characters (see Search for -MaxCharLength
) for XML or char data types.
Try the following:
$x = Invoke-SqlCmd -Server xxxx $sql -MaxCharLength <some large enough number>
Upvotes: 33
Reputation: 61
Many times this solves the case:
$x = Invoke-SqlCmd -Server xxxx $sql -MaxCharLength <some large enough number>
However, there are some cases where it doesn't work:
You could try couple of solutions:
Upvotes: 4