BOM characters in text file exported from SQL Server
Not sure if this is in the right group within the forum, but here goes.......I'm using SQL Server Management Studio to query a database and then using the "Results to File" function to put the data in a text file. Works great, except for the fact that
I get some extra characters at the beginning of my text file. The research I've done to this point leads me to believe that they are "BOM" characters (hex EF BB BF). They dont' show up within Notepad, but when I look at the file with a hex editor
right after I export it there they are. It causes me problems down the line when I try to import the file to another system.
Is there a setting in SQL Server that controls this? I can't for the life of me find one. I can easily enough remove the hex characters in my hex editor, but I'm trying to automate this process as much as possible and this little issue isn't
helping.
Any help anyone could provide would be appreciated. Thanks in advance.
June 21st, 2011 5:12pm
Yeah, basically this is not the right forum for you, but I will try to answer your question regardless:
use Data Export Import Wizard to extract the data to the flat file, since you need to automate the procedure, you can save it as a package that you can run again and even do modifications
to it.
Details on how to set it up: http://www.databasejournal.com/features/mssql/article.php/3580216/SQL-Server-2005-Import--Export-Wizard.htmArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
June 21st, 2011 5:29pm
Arthur,
I'd like to ask another quick question if I may. Previously I was accomplishing the exporting of this data by simply copying the data from the SQL Server query screen and pasting it into Excel, then creating a text file from there. I notice in
using the Export Wizard that for null-capable fields, it doesn't show anything in the text file. With my previous method it put the word "NULL" in there. I've built my mapping on the other system the destination of this data) to look
for the word 'NULL' in some of the fields and perform logic based on that. Is there a way using the Wizard to have it put the word 'NULL' in there in the same fashion? I've tried editing the mapping as I go through the Wizard and that doesn't seem
to do it. Any thoughts?
June 21st, 2011 7:18pm
Arthur,
Nevermind. I was able to figure a workaround for this problem. I check my text file for the hex value for the tab, and the tab still exists even though the word "NULL" is not there. So I just changed my logic to search for blanks
instead of the word "NULL" between the tabs. Works like a charm. Thanks again for your help.
Free Windows Admin Tool Kit Click here and download it now
June 21st, 2011 9:49pm