谢谢。使用 select @@identity
需要用到事物吗?
需要用到事物吗?
解决方案 »
- 如何根据两张表来统计村的个数 按镇名称排列
- 简单问题,合并查询结果
- 查找文件或文件夹
- 如何利用sqlserver中的事件跟踪器。在一个前端软件执行了一个插入语句的动作,想看看它所影响到了哪些表。
- Error at destination for Row number 100是什么错误啊,100分,在线等,谢谢
- Sql Server 2005 怎么实现双机热备份?
- 奇怪的问题
- 求2条查询语句
- 请大家看看,能不能帮我一下!我给高分!
- 我要选哪一本参考书比较好呢?
- select 能否将sum()的值存给个变量呢
- why:The value you entered is not consistent with the data type of length of the column
使用
select @@identity
需要添加事物吗?begin tran
... 要放到这里面吗?
commit tran
set rsIdentity = SQLconn.execute( strSQL )
if not rsIdentity.eof then
rsIdentity.movefirst
while not rsIdentity.eof
Id = rsIdentity(0)
rsIdentity.movenext
wend
end if
如果发生并发怎么办?在我想要获得 id 时,刚好有其他人添加记录,那么这时的@@identity返回的是别人(刚刚)添加的ID,还是?????
使用
select @@identity
需要添加事物吗?begin tran
... 要放到这里面吗?
commit tran
可以不用事务.因为@@identity是sql2000的全局变量
但一定要注意select @@identity语句紧跟insert语句后面
Insert into t('test')
select @@identity