我的表格列(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表中的行数
发布评论