Home All Groups Group Topic Archive Search About

Temporary table to a file

Author
1 Sep 2005 12:39 PM
Chandra
what is wrong with the following statements??

set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword'

exec master..xp_cmdshell @str

Author
1 Sep 2005 12:41 PM
Chandra
Hi

u need to try it as:
set @str = 'bcp TEMPDB..#temp out OutPutfile /c /Sservername /Usa /Ppassword'

temporary tables are stored in 'Tempdb' database



--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---------------------------------------



Show quote
"Chandra" wrote:

> what is wrong with the following statements??
>
> set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
>
> exec master..xp_cmdshell @str
>
>
Author
1 Sep 2005 12:51 PM
Chandra
Nope !!

it's not working !!!

could you please let me know any other solution

thanks


Show quote
"Chandra" wrote:

> Hi
>
> u need to try it as:
> set @str = 'bcp TEMPDB..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
>
> temporary tables are stored in 'Tempdb' database
>
>
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---------------------------------------
>
>
>
> "Chandra" wrote:
>
> > what is wrong with the following statements??
> >
> > set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
> >
> > exec master..xp_cmdshell @str
> >
> >
Author
1 Sep 2005 12:55 PM
Chandra
well I am sorry.

you cannot access Temporary objects from a different session.
the scope doesnt permit u

--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---------------------------------------



Show quote
"Chandra" wrote:

> Nope !!
>
> it's not working !!!
>
> could you please let me know any other solution
>
> thanks
>
>
> "Chandra" wrote:
>
> > Hi
> >
> > u need to try it as:
> > set @str = 'bcp TEMPDB..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
> >
> > temporary tables are stored in 'Tempdb' database
> >
> >
> >
> > --
> > best Regards,
> > Chandra
> > http://chanduas.blogspot.com/
> > http://www.SQLResource.com/
> > ---------------------------------------
> >
> >
> >
> > "Chandra" wrote:
> >
> > > what is wrong with the following statements??
> > >
> > > set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
> > >
> > > exec master..xp_cmdshell @str
> > >
> > >
Author
1 Sep 2005 12:55 PM
Mike Epprecht (SQL MVP)
Hi

A Temporary table is only in the scope of the batch or process and external
processes don't have access to it. OSQL is a differnt connection, hence a
different process.

You have to save the data in a permanent table.

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/



Show quote
"Chandra" wrote:

> Nope !!
>
> it's not working !!!
>
> could you please let me know any other solution
>
> thanks
>
>
> "Chandra" wrote:
>
> > Hi
> >
> > u need to try it as:
> > set @str = 'bcp TEMPDB..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
> >
> > temporary tables are stored in 'Tempdb' database
> >
> >
> >
> > --
> > best Regards,
> > Chandra
> > http://chanduas.blogspot.com/
> > http://www.SQLResource.com/
> > ---------------------------------------
> >
> >
> >
> > "Chandra" wrote:
> >
> > > what is wrong with the following statements??
> > >
> > > set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword'
> > >
> > > exec master..xp_cmdshell @str
> > >
> > >
Author
1 Sep 2005 12:59 PM
Aaron Bertrand [SQL Server MVP]
> what is wrong with the following statements??
>
> set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa
> /Ppassword'
>
> exec master..xp_cmdshell @str

xp_cmdshell has absolutely no idea what #temp is, because it lives in a
different scope.  You can try a global temp table or a permanent table, or
running the query from the command line instead of filling a #temp table.
Author
1 Sep 2005 2:16 PM
Hari Prasad
Hi,

# temp table will not be in the scope for the next session. Try the global
temp table. Just add ## to the temp table.

Thanks
Hari
SQL Server MVP

Show quote
"Chandra" <Chan***@discussions.microsoft.com> wrote in message
news:F37C5A64-4F16-4FD6-AB8B-31CBB4F92941@microsoft.com...
> what is wrong with the following statements??
>
> set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa
> /Ppassword'
>
> exec master..xp_cmdshell @str
>
>

AddThis Social Bookmark Button