我在存储过程里要自动给一个表写入数据,其中主键字段是自动生成数据,应该怎么写    

解决方案 »

  1.   

    --试试?create procedure up_test
    @col1 varchar(10),--参数1
    @col2 varchar(10)--参数1
    as
    begindeclare @maxno varchar(10)
    select @maxno = isnull(max(no),0) from tbname
    set @maxno = @maxno+1.....end
      

  2.   

    列属性设置为identity自动生成
      

  3.   

    在什么地方设置这个属性  identity自动生成
      

  4.   

    标识列可以显示的插入值set identity_insert tbname oninsert into tbname(id,name) select 3,'tname'set identity_insert tbname off
      

  5.   


    表->右击设计表->找开你要设置的列,->在属性里.设置标识为"是"
      

  6.   

    一般的主键就是identity除至之外就是自己写个函数