Error with SQL Server 2008 stored procedure bcp

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!
newtoperlpgmAsked:
Who is Participating?
 
Barry CunneyConnect With a Mentor Commented:
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
 
newtoperlpgmAuthor Commented:
BCUNNEY,
You mean post the output that I get when I execute the stored procedure?  Thank you.
0
 
Barry CunneyCommented:
Hi newtoperlpgm
Yes that is correct, the output that you get when you execute the dbo.OneRecordEntered stored procedure
0
 
newtoperlpgmAuthor Commented:
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
 
newtoperlpgmAuthor Commented:
Yup, that was my problem, I forgot to add my sql to my stored procedure.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.