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.
| Author |
Topic |
|
CLages
Posting Yak Master
116 Posts |
Posted - 2006-10-20 : 12:29:07
|
| hi,i would like to know how to Export a Table to TXT file without using DTS.A few weeks ago somebody sent to me a Sample, but i Lost.Searching im FAQ i did not anythingtks for nay replyClages |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-20 : 12:37:14
|
| Take a look at this topic, on using BCP to do ithttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73728 |
 |
|
|
CLages
Posting Yak Master
116 Posts |
Posted - 2006-10-20 : 13:18:10
|
| I found this and help meBut i Still remember something where i run intoQuery analizer.Tks AnywayClagesposted on Wednesday, October 26, 2005 5:19 AM by MadhivananBCP - Export data to Text FileHere is a simple method of exporting all the data from SQL Server table to a Text FileCREATE Procedure BCP_Text_File( @table varchar(100), @FileName varchar(100) ) as If exists(Select * from information_Schema.tables where table_name=@table) Begin Declare @str varchar(1000) set @str='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table+'" queryout "'+@FileName+'" -c''' Exec(@str) endelse Select 'The table '+@table+' does not exist in the database' Execute this procedure by giving Table Name and the File NameEXEC BCP_Text_File 'Employee','C:\emp.txt'Now all the data from Employee table will be exported to the text file which will be located at C:\emp.txt |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-21 : 06:34:17
|
| Thanks. You need to run the procedure in QA by supplying values to parametersMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|