获取SQL表中的行数

编程入门 行业动态 更新时间:2024-10-23 22:34:11
本文介绍了获取SQL表中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的表格列(studentID,studentName,studentRegNumber) 当我输入studentID和studentName时,应通过考虑表中的当前记录数来自动添加studentRegNumber. 示例记录 StdID StdName StdRegNo 1尼山A1 2布赖恩A2 3托马斯A3 应该这样自动添加StdRegNumber.. 给我一个例子... 因为我是c#

my table columns(studentID,studentName,studentRegNumber) when I enter studentID & studentName studentRegNumber should be added automatically by considering current number of records in the table. Examples records StdID StdName StdRegNo 1 Nishan A1 2 Brian A2 3 Thomas A3 StdRegNumber should be added automatically like this.. Give me a help with an example... Because I am a beginner for c#

推荐答案

Hi Nishan,的初学者 您需要使用ID的自动增量创建表. 请参考下面的链接来创建或更改表. www.sitepoint/forums/showthread.php?41676-Auto-Increment-primary-key-in-MS-SQL-server [ ^ ] howtoideas/how-to-create- auto-increment-column-in-a-sql-server-table [ ^ ] Hi Nishan, You need to create table with autoincrement of id. Refer below link to create or alter table. www.sitepoint/forums/showthread.php?41676-Auto-Increment-primary-key-in-MS-SQL-server[^] howtoideas/how-to-create-auto-increment-column-in-a-sql-server-table[^]

查看您提供的示例数据,您无需使用你的桌子.您可以在查询本身中将A串联到您的学生ID并获得结果. Looking at the sample data you have provided you need not use the studentRegNumber column in your table. You can just concatenate an A to your student ID in your query itself and get the result. SELECT StdID, StdName, 'A' + CAST(StdID AS VARCHAR) AS StdRegNo FROM [YourTableName]

您可以使用身份(属性) [ ^ ]自动生成学生ID.

You can use IDENTITY (Property)[^] to auto generate the student ID.

更多推荐

获取SQL表中的行数

本文发布于:2023-10-19 14:49:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507842.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:行数   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!