SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 CONVERT to TEXT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CSK
Constraint Violating Yak Guru

USA
489 Posts

Posted - 09/19/2006 :  04:06:17  Show Profile  Send CSK a Yahoo! Message  Reply with Quote
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

Sweden
30250 Posts

Posted - 09/19/2006 :  04:11:00  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

USA
489 Posts

Posted - 09/19/2006 :  04:13:11  Show Profile  Send CSK a Yahoo! Message  Reply with Quote
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)

Singapore
17638 Posts

Posted - 09/19/2006 :  04:19:55  Show Profile  Reply with Quote
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

USA
489 Posts

Posted - 09/19/2006 :  04:23:12  Show Profile  Send CSK a Yahoo! Message  Reply with Quote
Thanks Khtan,
I will download the BOL from links provided by you

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000