使用SQL 2005在Vb.net中自动增加ID [英] Auto Id Increment in Vb.net with Sql 2005

查看:95
本文介绍了使用SQL 2005在Vb.net中自动增加ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想增加id值,但其数据类型为varchar.id包含一些前缀作为字母
例如TYCS001

我想要ID系列TYCS002 ......等等
但是在我的代码中,当Id值达到TYCS010时,我得到的下一个自动ID是TYCS009.在这种情况下,请帮助我....

I want to increment id value but its datatype is varchar.The id contain some prefix as alphabet
e.g TYCS001

I want id series TYCS002......and so on
but with my code when the Id value reaches to TYCS010 then the next auto id i am getting is TYCS009.Please help me out in this case....

推荐答案


尝试以下sql:

Hi,
Try the following sql:

SELECT 'TYCS' + CONVERT(varchar, ROW_NUMBER() OVER(ORDER BY [Value])) as RowNumber,
* FROM [Practice].[dbo].[Table_A]


这篇关于使用SQL 2005在Vb.net中自动增加ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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