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)
 Records into text file

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-30 : 08:49:07
Kathiravan writes "I need a stored procedure that will have 5 to 10 input parameters which will return 50,000 to 2,50,000 records into text file.

The records will contain 22 columns with string,integer,double and datetime datatypes.

I need a help to solve this.

Thanks in advance."

nr
SQLTeam MVY

12543 Posts

Posted - 2005-05-30 : 09:47:15
Use bcp.

Create an sp to format the resultset - test that until you are happy.
Then you have a choice. You can change that SP so that instead of producing a resultset it uses bcp to output the text file.
Or (and I prefer) you can create another sp which just does the bcp using queryout with the formatting sp as input to create the file - in that way if you decide to change the way the file is created or change the destination you only change the shell sp.

note: If you use a temp table in the frmt sp you will probably need to include set fmtonly off in the calling command to get it to work.

==========================================
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
   

- Advertisement -