Friday, May 8, 2015

SQL Server is cutting off the result-output running a powershell script

The output from xp_cmdshell is a table with single column of the type nvarchar(255). Whence any truncation.

A better alternative is to write a CLR stored procedure to run the Powershell script and digest the output. It could return the data as a result set, which you could capture with INSERT-EXEC, or it could insert the data directly into the temp table. (I would pass the name of the temp table as parameter to the stored procedure.)


Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment