Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how to insert automatically generating sequence number into mssql database?

I am making a website with a number of aspx pages in vb.net using visual studio.

I have a table with column names [RoleName] and [Permission]

I am using sql query to insert rolename and permission data from textbox into sql database

rolename data is fetched from textbox input.

but the permission database should automatically be generated in sequence number such as 1-100.

How can i accomplish this please help me



thanks
Posted
Comments
Mathi Mani 12-Nov-15 20:20pm    
I think what you need to use is IDENTITY at the database level for the column you want to be in sequence and auto generated.
Member 12111217 12-Nov-15 22:48pm    
I already have the id field which is Role_ID field. I just want permission field to be auto generated incrementally

1 solution

As mentioned in comments, add a field to your table and make it an identity field. That will allow SQL to auto increment the value.

https://msdn.microsoft.com/en-us/library/ms186775.aspx[^]
 
Share this answer
 
Comments
Member 12111217 12-Nov-15 22:48pm    
I already have the id field which is Role_ID field. I just want permission field to be auto generated incrementally
ZurdoDev 13-Nov-15 7:08am    
If you want permission field to be auto generated and incremented then make it an identity field.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900