|
-
Feb 15th, 2007, 11:05 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] SQL Server CE autoIncrement???
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
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Feb 15th, 2007, 11:17 AM
#2
Re: SQL Server CE autoIncrement???
When your create the table use the identity keyword.
Code:
key decimal(18, 0) IDENTITY (1, 1) NOT NULL
"The dark side clouds everything. Impossible to see the future is."
-
Feb 16th, 2007, 03:52 AM
#3
Thread Starter
Fanatic Member
Re: SQL Server CE autoIncrement???
Works perfectly. Thanks 
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Feb 16th, 2007, 03:53 AM
#4
Member
Re: [RESOLVED] SQL Server CE autoIncrement???
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.
-
Feb 16th, 2007, 04:32 AM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] SQL Server CE autoIncrement???
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
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|