问题
I am using SQL Server Management Studio to export the results of my query to text. I would like to export the results without the character NULL being printed between delimiters.
For example, instead of:
,NULL,
I would like to export:
,,
Thanks for your help
回答1:
Just simply use
ISNULL(someColumn, '')
in our query. This will replace all NULL
values with an empty string
回答2:
It depends on how you export the data. If you use the Import and Export Wizard, the NULL strings do not show up in the result file (tested with SQL Server Management Studio 2014).
Select Tasks -> Export Data... In the dialog where you choose the destination, select "Flat File Destination". You can then write a custom query to select the data.
来源:https://stackoverflow.com/questions/17323446/ms-sql-server-export-results-to-file-without-null