February 5, 2009 at 4:07 am
I have a sql 2005 db used to archive hundreds of csv files that i store in a varchar(max) field. I've written a sproc to get a csv out again to the file system using the following code:
SET @cmd = 'bcp "SELECT Document FROM CSV_Archive.dbo.DocStore WHERE DocID ='+ CAST(@DocID AS VARCHAR)+'" queryout '+@oFile+' -S -T -N';
EXEC master..xp_cmdshell @cmd;
The resulting file contains some additional characters at the begining of the file - like so:
Ü‚NUL NUL NUL NUL NUL NUL.
Then the rest of the file is as it should be.
Any idea how I can avoid getting these unwanted extra characters?
February 11, 2009 at 4:15 pm
Do you not want the character that you listed on the left of your sample?
I would assume that it is exporting "column","column","column"...
If that is the case where your unwanted character is showing up I would look at the data type for that column. If your sample is a string then just use a 'Ltrim'.
February 12, 2009 at 7:31 am
It could be that the csv files loaded had foreign characters or additional formatting characters which could not be blatantly seen and may need to be fixed/filtered?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply