Hi guys,
How do i get a column in one of my tables to auto increment everytime i add a new row???
I am using Sql Server CE and am fairly new to databases and sql.
Thanks in advance for any help
:afrog:
Printable View
Hi guys,
How do i get a column in one of my tables to auto increment everytime i add a new row???
I am using Sql Server CE and am fairly new to databases and sql.
Thanks in advance for any help
:afrog:
When your create the table use the identity keyword.
Code:key decimal(18, 0) IDENTITY (1, 1) NOT NULL
Works perfectly. Thanks :thumb:
:wave:
You could just take care of this yourself.
Just run a sql statement to see what the max value for that column is and then add one to it then run the insert statement using this new value for one of the columns.
I knew i could've done that but i also knew there was an easier way to do it which is why i asked.
Its a lot neater and its one line of code whereas if i'd did it the way you suggest then it would've been a lot more!
Thanks anyways