Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bcp utility... help pls.

Status
Not open for further replies.

coolphilboy

Technical User
Aug 19, 2001
19
0
0
PH
Is it possible to invoke bcp utility in s stored procedure? If it is, can somebody help me how? TIA :cool:
 

You can execute BCP from a stored procedure by using xp_cmdshell.

Export example:
xp_cmdshell 'bcp servername..tablename out \\server01\share\bcp.fil .............'

Which version of SQL Server are you running? There may be better methods than running BCP from the procedure. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
I'm using SQL Server 7.0, what other solutions seems to be a better one than using bcp in a stored procedure to export sql table to plain text file? thanks for the help.
 
As I said, "There may be better methods ..." In this case, I'd have to know what kind of processing you do in the procedure. OSQL, Data Transformation Services (DTS) and writing your own extended SP are other possibilities.

Check the SQL FAQ for more info about writing to a text file from a SQL procedure.

Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Terry!
When would you use and extende SP to import and export data to a SQL Db? Which benefits would profit from using it? AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 

I've never ventured into writing my own extended stored procedure. I only mentioned it because it is an available method listed in the SQL FAQ. You need to ask someone with experience how to do it.

I would think you would write your own XP if you had requirements that couldn't be accomplished with existing methods. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Ohh! Ok thanks any way! AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top