Re: bcp error when queryout is stored procedure

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



[code]
alter PROC dbo.P_TMP
AS
BEGIN
SET NOCOUNT ON
SELECT * FROM SYSOBJECTS
END
go
[/code]
It should work.

Cristian Lefter, SQL Server MVP

"vygandas" <vygandas@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BB661426-5BEE-4420-A122-C875A48500A5@xxxxxxxxxxxxxxxx
>I am receiving an error when executing bcp out and queryout is "exec stored
> procedure". Please see details below:
>
> use workarea
> go
>
> if object_Id('P_TMP') is not null drop proc P_TMP
> go
>
> create PROC dbo.P_TMP
> AS
> BEGIN
> SET NOCOUNT ON
> SELECT * INTO #TMP FROM SYSOBJECTS
> SELECT * FROM #TMP
> END
> go
>
> exec MASTER..XP_CMDSHELL 'BCP "EXEC workarea.dbo.P_TMP" QUERYOUT
> "C:\Temp\TMP.TXT" -c -Ssqldev -N'
>
> ------------
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
> '#TMP'.
>
>


.



Relevant Pages