Wednesday, March 21, 2012

Is that possible to BCP queryout from a #tmptable?

I have create a #tmptable and want to bcp queryout

SET @.bcpCommand = 'bcp "select * from #tblDisplay" queryout "c:\HAK.csv " -c -t -r\n -m100 -Usa -P -SNisdev4

execute master..xp_cmdshell @.bcpCommand

But it say "no #tmptable this object".

what can i do?

PLS HELP.
thank you

ami:(The problem is that you created #tmptable in one session but were trying to reference it while in another session (BCP). By design a temp table is ony visable to the session it was created in.

If you are using SQL2K you can create a global temp table ## rather than #. look up "CREATE TABLE" in Books On Line and go dwon to the "Temporary Tables" section for more info.

No comments:

Post a Comment