如何用下列语句作用到临时表呢?
select * into #v from (select * from sddata where txndate < '2007-1-11 ')a
EXEC master..xp_cmdshell 'bcp "tempdb.dbo.#v " out "c:\b.txt " /S "localhost " /U "sa " /P "sa " -c '
服务器返回#v无效.
不知怎么能使用到临时表?
thanks
------解决方案--------------------实在不行,可以先创建一个临时表,用完后再删除
create table V()
insert into select * into V from (select * from sddata where txndate < '2007-1-11 ')a
EXEC master..xp_cmdshell 'bcp "tempdb.dbo.v " out "c:\b.txt " /S "localhost " /U "sa " /P "sa " -c '
drop table V
------解决方案--------------------是不是又新建了一个连接,所以临时表就不存在了.
要么改成
select * into ##v from (select * from sddata where txndate < '2007-1-11 ')a
EXEC master..xp_cmdshell 'bcp "tempdb.dbo.##v " out "c:\b.txt " /S "localhost " /U "sa " /P "sa " -c '