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 2005 Forums
 Transact-SQL (2005)
 bulk copy

Author  Topic 

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-05-04 : 08:11:12
Hi,

how to export table data to text file using bcp method or openrowset function.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-04 : 08:16:10
bcp mydb..mytbl out "c:\myfile.txt" -SServername -c -T

exec master..xp_cmdshell 'bcp mydb..mytbl out "c:\myfile.txt" -SServername -c -T'


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

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-05-05 : 00:49:15
data is not loading just its creating empty file..

THis what i am using

EXEC master.dbo.xp_CmdShell 'BCP "SELECT data FROM fts.dbo.fts_test out" QUERYOUT C:\TEMP.txt -T -f -S XXX\MSSQL'
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-05-05 : 01:36:30
thnaks i got it is mentiond -C then it start coping
Go to Top of Page
   

- Advertisement -