INSERT INTO #A Select * From @TableName
改为
select * into #A from @TableName

解决方案 »

  1.   

    Declare @chrTmp Varchar(100)
    declare @TableName varchar(50)
    set @TableName='sysct'Set @chrTmp = N'select * INTO #A From ' +@TableName --其实@TableName为传入的参数。
    set @chrTmp=@chrTmp +char(13) + 'select * from #A'
    --print @chrTmp
    Exec (@chrTmp)
      

  2.   

    这样是不行的,因为如果我要多次insert的话,不能每次都写select * INTO #A From tablename 吧,所以我先建了临时表,然后用insert into #A select * from tablename.
    请问有什么办法可以解决吗?