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
精彩评论