daletrotman
asked on
BCP warning messages when outputing XML
These warning messages are killing my processing time!
I am getting this warning message when running BCP within the SQL SERVER Query Analyzer FOR EVERY LINE CREATED!...
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Warning: Server data (3046 bytes) exceeds host-file field length (0 bytes) for field (1). Use prefix length, termination string, or a larger host-file field size. Truncation cannot occur for BCP output files.
Now I realise this is just a warning message and comes about because of the -r option with the BCP command. I have seen this post https://www.experts-exchange.com/questions/20546470/Save-to-XML-Stored-Procedure-500-points.html
bcp "SELECT * FROM [dbo].[_CommunityStaging] FOR XML AUTO, ELEMENTS" queryout c:\temp\_CommunityStaging. txt -Scas074\cas074 -c -r -T
...but it really hits the processing time!
If I run the same command without the -r (row terminator) option...
bcp "SELECT * FROM [dbo].[_CommunityStaging] FOR XML AUTO, ELEMENTS" queryout c:\temp\_CommunityStaging. txt -Scas074\cas074 -c -T
... it runs in 10 seconds but does not form proper XML due to the carriage return it places into the code. When run the correct way (first example) it takes 2 minutes 38 seconds.
This is not going to scale up well when I perform the same request on many tables!
My question is: Is there a way to stop the warning messages coming through and therefore speed up the processing?
If not is there a way to use another method to output the XML? I know osql is an option but this gives me an identifier at the begining of the file, loads of hyphens, and loads of spaces between XML. Completely useless to me.
Many thanks in anticipation
Dale
I am getting this warning message when running BCP within the SQL SERVER Query Analyzer FOR EVERY LINE CREATED!...
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Warning: Server data (3046 bytes) exceeds host-file field length (0 bytes) for field (1). Use prefix length, termination string, or a larger host-file field size. Truncation cannot occur for BCP output files.
Now I realise this is just a warning message and comes about because of the -r option with the BCP command. I have seen this post https://www.experts-exchange.com/questions/20546470/Save-to-XML-Stored-Procedure-500-points.html
bcp "SELECT * FROM [dbo].[_CommunityStaging] FOR XML AUTO, ELEMENTS" queryout c:\temp\_CommunityStaging.
...but it really hits the processing time!
If I run the same command without the -r (row terminator) option...
bcp "SELECT * FROM [dbo].[_CommunityStaging] FOR XML AUTO, ELEMENTS" queryout c:\temp\_CommunityStaging.
... it runs in 10 seconds but does not form proper XML due to the carriage return it places into the code. When run the correct way (first example) it takes 2 minutes 38 seconds.
This is not going to scale up well when I perform the same request on many tables!
My question is: Is there a way to stop the warning messages coming through and therefore speed up the processing?
If not is there a way to use another method to output the XML? I know osql is an option but this gives me an identifier at the begining of the file, loads of hyphens, and loads of spaces between XML. Completely useless to me.
Many thanks in anticipation
Dale
Consider writing a VB or .NET app to extract the Xml data. It should not be more than 10 lines of code (depending on the number of parameters).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.