June 2, 2010 at 1:57 am
hi,
iam new to sql server. iam doing a project that uses sql server 2005 express edition as back end and access as front end.
what is the equivalent of autonumber in sql server?
Ms access (Auto Number) = sql server 2005 express edition (?)
please help me.
regards,
kiran
June 2, 2010 at 2:01 am
Identity
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 2, 2010 at 2:39 am
To illustrate what Gail had said , here is a small sample code that will auto-increment a column using IDENTITY column; execute the code in your SQL Express ; follow the comments in the code to understand.
DECLARE @Table TABLE
(
AUTO_ID INT IDENTITY(1,1), -- IDENTITY(1,1) = It starts at 1 and gets incremented by 1
ALPHA VARCHAR(1)
)
INSERT INTO @Table (ALPHA) -- Look here, i am using only the ALPHA column, the AUTO_ID will incremet automatically
SELECT 'A'
UNION ALL SELECT 'B'
UNION ALL SELECT 'C'
UNION ALL SELECT 'D'
UNION ALL SELECT 'E'
UNION ALL SELECT 'F'
SELECT AUTO_ID, ALPHA FROM @Table
To learn more about IDENTITY, click on the following link.
Link : IDENTITY (Property) (Transact-SQL)
Hope this helps you!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply