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 data

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-14 : 07:26:18
m.nazari writes "hello
how can i export data from sql server to text file with a sql command ( i want to run it in store procedure >?

m.nazari"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-14 : 07:47:31
[code]
Create Procedure ExportToText (@DBName varchar(100),@tableName varchar(100))
as
Exec('Exec Master..xp_cmdShell ''bcp "Select * from '+@DBName+'..'+@tablename+'" queryout "C:\text.txt" -c''')
[/code]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -