Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

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

Constraint Violating Yak Guru

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

Patron Saint of Lost Yaks

30421 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.
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

Constraint Violating Yak Guru

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

Go to Top of Page

In (Som, Ni, Yak)

17689 Posts

Posted - 09/19/2006 :  04:19:55  Show Profile  Reply with Quote
you can download or refer it online. See this thread,on,line


Go to Top of Page

Constraint Violating Yak Guru

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  
 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.05 seconds. Powered By: Snitz Forums 2000