exec('declare @indextable table(id int identity(1,1),nid int) insert into @indextable(nid) select NewsID  from NewsTable '+@sqlWhere+' select * from @indextable')

解决方案 »

  1.   

    insert into @indextable(nid) 
    exec('select NewsID  from NewsTable '+ @sqlWhere)
      

  2.   

    insert into @indextable(nid) 
    exec('select NewsID  from NewsTable ' + @sqlWhere)
      

  3.   

    不行啊,邹老大:错误 197: 无法在向表插入变量时将 execute 用作源
      

  4.   

    USE tempdb
    GOCREATE TABLE tb(
    ID char(16) PRIMARY KEY
    DEFAULT LEFT(NEWID(), 16),
    Name sysname)
    GOINSERT tb(Name) SELECT Name FROM sysobjects
    GOSELECT * FROM tb
    GODROP TABLE tb