Ok, I'm not exactly sure this is an easy task so I hope im posting this in the right area.
What I have is a column in my SQL Server database that is just an ID number.
I had previously used Access and being SQL Server noob, I had no idea if it had a property type like Access' "AutoNumber". I just made it an integer
What I want to do though now, is assign ID's automatically to each new record by making it 1 above the most recently added one. There are two ways I've thought I can be helped:
1) Is there code to find the maximum value of a column in a database, return the value, and then add 1 to it?
or
2.) Can someone give me information about how I could use a feature like Access' AutoNumber in SQL Server?
THANKS GUYS FOR ALL YOUR HELP!In SQL server, you can make the column data type as integer and set identity = yes, identity Seed = 1 and identity Increment = 1 in Columns tab.|||IDENTITY in SQL Server is a property like Access Autonumber. Run a search for IDENTITY and IDENTITY Scope, IDENT_SEED, IDENT_INCR and SET IDENTITY_INSERT option and System varaible IDENTITYCOL in the BOL(books online) to get started. Hope this helps.|||
Worked out perfect, exactly what I was looking for!
Thanks a ton guys!
No comments:
Post a Comment