Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Exporting

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-16 : 09:26:24
Carsten writes "I'd like to export one or more tables to a textfile and make a job of it. What I need is a command string (if possible. if not - code for a stored procedure) to put in the create job wizard. Could you pls. help?

Carsten"

nr
SQLTeam MVY

12543 Posts

Posted - 2003-12-16 : 09:59:10
Look at bcp or osql

http://www.nigelrivett.net/WriteTextFile.html

You can create different files and concatenate them by

type file1.txt >> file2.txt



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Carsten
Starting Member

1 Post

Posted - 2003-12-16 : 10:26:19
Thanks. With some help from your link I managed to put together the following command

Exec master..xp_cmdshell 'bcp "Select * from i2000..Users" queryout c:\tmpBackup\Users.csv -t , -r \n -c -Craw -T -k'

Exports to a comma separated .csv file with national characters intact.

I then created a job with this command and it works like a charm.

Carsten
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-16 : 12:29:08
Since you are just creating a job, just use the cmdexec job step without xp_cmdshell. So you'd use bcp outside of xp_cmdshell.

Tara
Go to Top of Page
   

- Advertisement -