曾经爱晚人








永远自由的心

2006年10月18日

动态执行Sql语句与临时表的问题(对象名无效)

摘要: exec('selectIDENTITY(int,1,1) as ID,fnum,into #yuecu from store_store where '+@Parameter) select XX,XX1,XX2 from #yuecu . 这样创建一个临时表以后我再想从临时表中取数据提示对象名#yuecu 无效,晕,如果我不是使用exec()执行sql语句的话就没有任何问题,WHY? 临时表有作用域的,上面的临时表只在EXEC內部有效。 解决办法: 改用全局临时表 exec('selectIDENTITY(int,1,1) as ID,fnum,into ##yuecu from store_store where '+@Parameter) select * from ##yuecu 阅读全文

posted @ 2006-10-18 15:39 e旋风 阅读(5374) 评论(0) 推荐(0) 编辑

导航