IDENTITY COLUMN AT SQL

Hi All,

I create a identity column :

IdNo SmallInt IDENTITY(4,1)

I have some questions about it :

1. What does it mean ? How many number is the max number ?
2. How to call it using criteria ?

Thank you.
LVL 1
emi_sastraAsked:
Who is Participating?
 
Kelvin SparksConnect With a Mentor Commented:
It is an autonumbering column - in your case it will start from 4, and add 1 to the last used number. Generally used with int insteadof smallint. Provides a unique numbering of records - often for primary keys.

You don't call it

Kelvin
0
 
greischConnect With a Mentor Commented:
0
 
emi_sastraAuthor Commented:
Hi All,

What I mean call it means how to select it using query ?

What is the maximum number for Int and SmallInt ?

Thank you.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Rahul AgarwalTeam LeaderCommented:
It is like this

[IdNo] [smallint] IDENTITY(4,1) NOT NULL,

Means that as kelvin says starts from 4 and add 1 to every time the new record insert in the table, but it cannot take deleted [IdNo] value means say if you have 10 records 1-10 and delete the 10th record and insert new record then the [IdNo] takes the 11 not 10 again.
0
 
Rahul AgarwalConnect With a Mentor Team LeaderCommented:
Please check the link for all the datatype maximum value:

http://www.sql-server-helper.com/faq/data-types-p01.aspx
0
 
Kelvin SparksCommented:
Use it the same as any other field in a query

SELECT IdNo FROM yourtable INNER JOIN anothertable ON youtable.IdNo = anothertable.IDNo1
0
 
emi_sastraAuthor Commented:
SELECT * FROM yourtable WHERE IdNo = 10 ?

Thank you.
0
 
Kelvin SparksCommented:
Yes
0
 
emi_sastraAuthor Commented:
Hi All,

Thank you very much for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.