sql server 怎么记录最新插入的数据(没有自动增长列)?

来源:互联网 发布:孙总定制机箱淘宝店 编辑:程序博客网 时间:2024/05/16 15:48
 
 
--先定义变量@IdentityID 从A表中去取最大的编号赋给@IdentityID  select @IdentityID=max(IdentyID) from A  --如果A表中的最大的ID为空 就将1赋值给@IdentityID  select @IdentityID=isnull(@IdentyID,1)  ---再插入数据  insert into stb102(IdentyID,Node1,Node2,NodeValue,StrValue,EnabledUserID)   values( @IdentityID+IdentityID,@NodeID,@AttrID2,-1,'',@UserID)
原创粉丝点击