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
 Transact-SQL (2000)
 CONVERT to TEXT

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-19 : 04:06:17
Dear all,
I have a stored procedure, that has return some rows and i have shown in report. But instead of report I want to save it into flat file. (ie) Text file.

One Of my colleague suggest me to do in BCP. But i dont know how to do the BCP Utility.

How can i do this ?Please Give me some suggessions

thanks and regards
krishnakumar.C

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 04:11:00
I opened BOOKS ONLINE and found this when searching for BCP.
quote:
Copying Data From a Query to a Data File
The bcp utility allows you to copy the result set from a Transact-SQL statement to a data file. The Transact-SQL statement can be any valid statement that returns a results set, such as a distributed query or a SELECT statement joining several tables. For example, to copy the names of all the authors, ordered by surname, from the authors table in the pubs database to the Authors.txt data file, execute at the command prompt:

bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout Authors.txt -c -Sservername -Usa -Ppassword

Bulk copying data from a query is useful if you want to ensure that the order of the data is preserved in the data file; bulk copying data from a table or view does not guarantee the order of the data written to the data file. Preserving the order of the data in the data file allows you to make use of the ORDER hint when bulk copying data from the data file back into a table. Using the ORDER hint can significantly improve bulk copy performance. For more information, see Optimizing Bulk Copy Performance.

If the Transact-SQL statement returns multiple result sets, such as a SELECT statement that specifies the COMPUTE clause, or the execution of a stored procedure that contains multiple SELECT statements, only the first result set is copied; subsequent result sets are ignored.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-19 : 04:13:11
thanks PESO,

In My system , THE BOL IS not instllaed while installing the client connectivity.
Thats the problem while asking the SQL TEAM

Thanks
KK
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-19 : 04:19:55
you can download or refer it online. See this thread http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=71256&SearchTerms=books,on,line


KH

Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-19 : 04:23:12
Thanks Khtan,
I will download the BOL from links provided by you

Go to Top of Page
   

- Advertisement -