创建自动计数器1,2,3,4,5 ...等 [英] Create auto counter 1, 2, 3, 4, 5...etc

查看:161
本文介绍了创建自动计数器1,2,3,4,5 ...等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I need to insert new first column counter
1
2
3
4
5
6..etc in this code





我尝试过:





What I have tried:

String saveStaff = " Select  roba as 'Naziv artikla', SUM (cast(kolicina as float)) as 'Kolicina' from (select roba, kolicina from mp_racun_roba union all select roba, kolicina from mp_faktura_roba) as alltables group by roba";  

推荐答案

你的意思是你需要为插入的行生成一个新的唯一值吗?如果是这种情况,我不会在代码中执行此操作,而是让数据库为您创建密钥。



一种方法是使用IDENTITY定义一栏。看看 IDENTITY(属性)(Transact-SQL)| Microsoft Docs [ ^ ]
Do you mean that you need to generate a new unique value for the inserted row? If that is the case, I wouldn't do it in code but let the database create the key for you.

One way to do is to use IDENTITY definition for a column. Have a look at IDENTITY (Property) (Transact-SQL) | Microsoft Docs[^]


这篇关于创建自动计数器1,2,3,4,5 ...等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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