简体   繁体   English

如何生成制表符分隔的txt文件?

[英]How to generate tab-delimited txt file?

I want to use SQL SERVER 2005 commands to generate tab-delimited file. 我想使用SQL SERVER 2005命令生成制表符分隔文件。 I want to create a complex query and give it to something (say a function) to export data with columns names into a tab-delimited file. 我想创建一个复杂的查询并将其赋予某些东西(比如一个函数),以便将带有列名的数据导出到制表符分隔的文件中。

If u don't know something doing this, suggest an idea that reduces the headache of doing it from scratch using C#. 如果你不知道这样做的话,提出一个想法,减少使用C#从头开始做这件事的麻烦。

AHH, I am not willing to learn SSRS as I'm supposed to finish this in one day, but if this is the only way, tell me. 啊,我不愿意学习SSRS,因为我应该在一天内完成这项工作,但如果这是唯一的方法,请告诉我。

Thank u for ur time 谢谢你的时间

试用SQL Server bcp.exe工具

It is unclear from your question whether you just need to achieve the tab-delimited output, or whether you need to do it programmatically. 从您的问题中不清楚您是否只需要实现制表符分隔的输出,或者是否需要以编程方式进行。 If this is just for a one-off task, then I suggest you use SQL Server Management Studio. 如果这仅用于一次性任务,那么我建议您使用SQL Server Management Studio。

Go to Tools -> Options -> Query Results -> SQL Server -> Results to Text and set the output format to "Tab delimited". 转到Tools -> Options -> Query Results -> SQL Server -> Results to Text ,并将输出格式设置为“制表符分隔”。 Ok that change, then run your query using SSMS, making sure you have "Results to Text" enabled ( Query -> Results To -> Results to Text ). 好的改变,然后使用SSMS运行您的查询,确保您启用了“结果到文本”( Query -> Results To -> Results to Text )。 You will need to use a new query window as only new query windows pick up the settings changes. 您将需要使用新的查询窗口,因为只有新的查询窗口才会获取设置更改。

The output of your query should now show in the results window with tab delimiters. 现在,查询的输出应显示在结果窗口中,并带有制表符分隔符。

Obviously, this is not much help if you need to achieve this programmatically. 显然,如果您需要以编程方式实现此功能,这没有多大帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM