sqlserver中的自动递增问题 [英] Auto incrementing problem in sqlserver

查看:80
本文介绍了sqlserver中的自动递增问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用sqlserver 2008.I有一个问题。即如果假设一个表可以有2列id,name.Id是自动递增列。如果我有5行。如果我写了这样的查询

Hi,
Am using sqlserver 2008.I have one problem. i.e. if suppose a table can have 2 columns with id,name.Id is the auto incremented column.if i have 5 rows.if i wrote a query like this

select max(id) from table



它显示了5.

当我删除最后一行时它会显示结果4.

这里我想显示删除行的结果,结果是5 ..



谢谢


it is showing 5.
when ever i am deleting last row it will show the result 4.
Here i want to show the result with deleted row like the result is 5..

thank you

推荐答案

它会显示4因为max(id)将返回最大数字在id字段中,你不能再显示5,因为它不再存在,不再生成。
it will show 4 because max(id) will return maximum number in id field, there is no way u can show 5 no more, as it doesnt exist any more and will not be generated any more.


这篇关于sqlserver中的自动递增问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆