Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Or any other procedure to produce a formatted specimen...
I've tried some things. One that I though looked hopeful was via bcp and xp_cmdshell:
EXECUTE xp_cmdshell  'bcp "DECLARE @hdoc2 [int];DECLARE @doc2 [nvarchar](MAX);SET @doc2 = (SELECT LTRIM(RTRIM(REPLACE([xml],''UTF-8'',''UTF-16''))) FROM [database].[xml].[tblXMLIdx]);EXEC sp_xml_preparedocument @hdoc2 OUTPUT, @doc2 ; PRINT @doc2" queryout C:\Users\output\bcp_test_01.txt -c -T -S "computer\instance"'

But S is having none of it:
output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client]BCP host-files must contain at least one column
NULL

Apart from any semantic error that you can see here, has anyone ever successfully used this thing for a multiline, semi-colon-seperated, TSQL command string before?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900