开发者

TSQL QUERY to dump table into a file?

I want to dump a tale into a text file I am using following command -

bcp tablename out myTable.dat -T -C

But got error it says incorrect symbol near bcp.

I am not sure why I am开发者_高级运维 getting this.


From @Code Monkey's Link : http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/

try this

declare @sql varchar(8000)
select @sql = 'bcp [dbname].[dbo].[tablename] out myTable.dat -c -t, -T -S'+ @@servernameexec 
master..xp_cmdshell @sql

where dbname is the name of your database, and replace dbo with the name of the schema if not dbo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜