Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

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!
0
newtoperlpgm
Asked:
newtoperlpgm
  • 3
  • 2
1 Solution
 
Barry CunneyCommented:
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now