Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-06-06 : 09:19:16
|
| Ben writes "I was wondering if there is a way to have your primary key update when a record is added to the database.I am createing a gridview with records pertaining to events. At the bottom of my page I give the user an option to add an event to the gridview which means an event will be added to the database. I dont want the user to have to keep track of the EventID (which is just a number) to add records to the database. Thanks for any help." |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 09:32:14
|
You can use insert trigger to do this KH |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-06-06 : 10:57:40
|
Or maybe an identity column will work for you...--datadeclare @Event table (EventId int identity(1, 1), Event varchar(10))insert @Event (Event) values ('abc')insert @Event (Event) values ('xyz')select * from @Event/*resultsEventId Event ----------- ---------- 1 abc2 xyz*/Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
|
|
|