MS SQL Server - Export Results To File without “NULL”

痞子三分冷 提交于 2021-01-02 05:43:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!