SQL server identity column values use in table
Steps-Firstly Open-> Sql Server Create Table -> First Field Like ID Usually Autoincrement=>
Table create then=>insert data in table=> then Select data show increment id.
Table create then=>insert data in table=> then Select data show increment id.
The following SQL statement defines the "ID" column to be an auto-increment primary key field in the "Category" table (Given Category is Table Name and CategoryId And CategoryName are Field in Table
Create table Category
We use IDENTITY(1,1) in Table .
Create table Category
(
CategoryId INT IDENTITY(1,1) Primary Key,
CategoryName NVARCHAR(100)
)
We use IDENTITY(1,1) in Table .
Where the 1,1 is the starting number is 1 and increment by 1 that's the resion We use Identity(1,1)
In the example above, the starting value for IDENTITY is 1, and it will increment by 1 for each new record.
Exp. To specify that the "ID" column should start at value 10 and increment by 5, change it to IDENTITY(10,5).
In This Following Image CategoryId Is Auto Increment And Id id Start with 1 and It Will
Increment By 1
1. Create Table With Create Query.
2. Insert Data With Insert Query.
3. Show Table Data Through Select Query in Sql Server.
0 comments :
Post a Comment