-2
我想通过变量来创建临时表像下,但我没有得到错误SQL语句时,没有正确地从变量在SQL服务器执行
Declare @cSQL varchar(Max) = 'Select top 10 * into #TempTab from Customer'
EXEC (@cSQL)
select * from #TempTab
我收到以下错误
(10受影响的行)
消息208,级别16,状态0,行4
无效的对象名称#CurTemp。
http://stackoverflow.com/questions/2920836/local-and-global-temporary-tables-in- sql-server – fqhv
[T-SQL动态SQL和临时表]的可能重复(http://stackoverflow.com/questions/2917728/t-sql-dynamic-sql-and-temp-tables) –