|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Temporary table to a filewhat is wrong with the following statements??
set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa /Ppassword' exec master..xp_cmdshell @str 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 -- Show quotebest 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 > > 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 > > > > well I am sorry.
you cannot access Temporary objects from a different session. the scope doesnt permit u -- Show quotebest Regards, Chandra http://chanduas.blogspot.com/ http://www.SQLResource.com/ --------------------------------------- "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 > > > > > > 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 > > > > > > > what is wrong with the following statements?? xp_cmdshell has absolutely no idea what #temp is, because it lives in a > > set @str = 'bcp mydb..#temp out OutPutfile /c /Sservername /Usa > /Ppassword' > > exec master..xp_cmdshell @str 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. 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 > > |
|||||||||||||||||||||||