Showing posts with label increament. Show all posts
Showing posts with label increament. Show all posts

Sunday, February 12, 2012

Auto key generation

Hi,

Can any one tell me how can I create auto number (similar feature to MS Access) i.e. autmatic increament by 1 in MS SQL 2005 (without using any script)

make the column an identity

CREATE TABLE test(id INT IDENTITY, SomeOtherVAlue varchar(50))

INSERT test VALUES( 'A' )
INSERT test VALUES( 'B' )
INSERT test VALUES( 'C' )
INSERT test VALUES( 'D' )
INSERT test VALUES( 'E' )
INSERT test VALUES( 'F' )
GO

SELECT * FROM Test

id SomeOtherVAlue
-- --
1 A
2 B
3 C
4 D
5 E
6 F

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

i have to got the answer

Use Identity Specification property of column

auto Increament

hello to all,

In Sql Server 2005, how to create a column that is Auto Increamented ?

It's a int or bigint column that has the identity attribute. (Only one column per table may have that attribute).

auto increament

how to auto increament fieldname id which is set as a primary key in sqlserver 2005 inasp.net2.0

You can't really do this from within ASP.NET. The only real way to do this is to change your key to be an identity field within SQL server.