Solved

# IDENTITY COLUMN AT SQL

Posted on 2011-03-17
366 Views
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.
0
Question by:emi_sastra
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3
• 2
• +1

LVL 22

Accepted Solution

Kelvin Sparks earned 200 total points
ID: 35154909
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

LVL 3

Assisted Solution

greisch earned 200 total points
ID: 35154927
0

LVL 1

Author Comment

ID: 35154954
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

LVL 13

Expert Comment

ID: 35154961
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

LVL 13

Assisted Solution

agarwalrahul earned 100 total points
ID: 35154970

http://www.sql-server-helper.com/faq/data-types-p01.aspx
0

LVL 22

Expert Comment

ID: 35155001
Use it the same as any other field in a query

SELECT IdNo FROM yourtable INNER JOIN anothertable ON youtable.IdNo = anothertable.IDNo1
0

LVL 1

Author Comment

ID: 35155010
SELECT * FROM yourtable WHERE IdNo = 10 ?

Thank you.
0

LVL 22

Expert Comment

ID: 35155022
Yes
0

LVL 1

Author Comment

ID: 35155056
Hi All,

Thank you very much for your help.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

T-sql Date Format 9 67
online  environment for testing sql queries 5 40
Problem with MySQL query - graph 3 47
Error creating summetric key on SQL 2012 (Amazon) 7 48
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Six Sigma Control Plans
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
###### Suggested Courses
Course of the Month2 days, 7 hours left to enroll