Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error with SQL Server 2008 stored procedure bcp

Posted on 2013-12-19
5
Medium Priority
?
729 Views
Last Modified: 2014-01-02
In Sql Server 2008 I created a stored procedure to select data from a table.  I am trying to output the results to a csv file.  When I execute it I get an error

bcp host-files must contain at least one column

My procedure is below:
CREATE procedure [dbo].[OneItemEntered]
as
begin
DECLARE @FileName varchar(200), @bcpCommand varchar(4000)
SET @FileName = REPLACE('c:\temp\OneRecord'+CONVERT(char(8),GETDATE(),1)+'.csv','/','-')
--SET @bcpCommand = 'bcp "EXEC dbo.OneRecordEntered" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -T -c'
end

Thanks!
0
Comment
Question by:newtoperlpgm
  • 3
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 2000 total points
ID: 39731808
Hi newtoperlpgm
The stored procedure which you are supplying to the BCP command is dbo.OneRecordEntered

In SQL Server Management Studio Query window please execute
exec dbo.OneRecordEntered

and then post up the output
0
 

Author Comment

by:newtoperlpgm
ID: 39732078
BCUNNEY,
You mean post the output that I get when I execute the stored procedure?  Thank you.
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 39732386
Hi newtoperlpgm
Yes that is correct, the output that you get when you execute the dbo.OneRecordEntered stored procedure
0
 

Author Comment

by:newtoperlpgm
ID: 39732846
Alas, I realize I did not have my select statement in my procedure.  I will add and see what, if any, errors I come up with when I execute.  Thank you.
0
 

Author Comment

by:newtoperlpgm
ID: 39752477
Yup, that was my problem, I forgot to add my sql to my stored procedure.  Thank you.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question