0

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.

2
  • see here - simple-talk.com/sql/database-administration/… Commented Sep 9, 2011 at 0:31
  • bcp is a command-line program. You need to specify the database and owner, and can run it from your workstation (might need to provide -S, -U and -P parameters for authentication). I usually use -c -t to produce tab-delimited files that can be loaded or pasted into Excel easily. Commented Sep 9, 2011 at 1:47

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.