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 2005 Forums
 Other SQL Server Topics (2005)
 BCP and Stored Procedures

Author  Topic 

morphviper
Yak Posting Veteran

60 Posts

Posted - 2007-04-13 : 15:21:53
I have a stored procedure that is rather large and creates nicely formatted XML in a cell.

Now what I want to do is get that cell into an xml file. I have found tons of articles, but none seem to fit my needs.

I figured I would use BCP, but I cant seem to get it to work calling a stored procedure where I need to pass one parameter into the stored procedure.

so I am really confused. Any help or pointing me to some articles that use BCP and stored procedures where they need to be passed a parameter

Thank you for any assistance!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-13 : 16:14:23
Please show us an example.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

morphviper
Yak Posting Veteran

60 Posts

Posted - 2007-04-13 : 16:48:33
bcp "EXEC RDC..CreateXML" queryout c:\Testingxml.xml -c -Uuser -Ppass

I am having trouble even getting this to work, but I need something like this but In need to send a parameter.

what I send in query analyser is:
exec createxml 1

I was also looking at xp_cmdshell?
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-04-13 : 16:55:59
nr has a lot of detail about how to use bcp and sprocs here:

http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/


www.elsasoft.org
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-04-13 : 17:01:42
I havent used BCP + stored proc..but just a thought...
You can create a temp table and use INSERT INTO EXEC to get the results into the temp table. Then you can use BCP to just create a file and do SELECT * FROM #tmp..

CREATE TABLE #tmp...

INSERT INTO #tmp EXEC <stored proc> <params>

xp_cmdshell 'bcp queryout "SELECT * FROM #tmp" ....'




************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -