declare @f1 as intset @f1=20  /* @f1的值是从另一个表中取得的,我这里写了一个固定值 */
select identity(int,@f1,1)
into #temp1
 from tblInfo 系统提示语法错误,如何来写?

解决方案 »

  1.   

    declare @f1 as intset @f1=20  /* @f1的值是从另一个表中取得的,我这里写了一个固定值 */select identity(int,0,1) as id--identity 的参数只能是常量
    into #temp1
    from tblInfoupdate #temp1
    set id = id + @f1 
      

  2.   

    也可以如下:
    declare @f1 as int
    set @f1=20  /* @f1的值是从另一个表中取得的,我这里写了一个固定值 */
    declare @sql as varchar(8000)
    set @sql = 'select identity(int,'+ str(@f1) +',1) as id into #temp1 from t_test select * from #temp1 '
    exec(@sql)