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 - 2005-08-23 : 07:34:07
|
| Gerry writes "I've been trying to find a way to retrieve the unique identifier of a newly inserted row.I have a table with the primary key defined on a unique identifier type column. I gather information from a client through an ASP web page and insert the data into the table. Upon inserting the data, the default value for the unique identifier calls the NewID() function. However, I cannot seem to find something comparable to @@IDENTITY as used in the below code.Dim db,rcs,new_identity'Create a database connectionSet db = Server.CreateObject("adodb.connection")db.Open "DSN=MyDSN"'Execute the INSERT statement and the SELECT @@IDENTITYSet rcs = db.execute("insert into tablename (fields,..) " & _ "values (values,...);" & _ "select @@identity").nextrecordset'Retrieve the @@IDENTITY valuenew_identity = rcs(0)Any help would be greatly appreciated.Gerry" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
bell27
4 Posts |
Posted - 2005-08-23 : 11:03:45
|
Thats the way it is done do you not think so. <edit> spam links removed </edit> |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-24 : 02:05:15
|
quote: Originally posted by bell27
Thats the way it is done do you not think so. <edit> spam links removed </edit>
Which way? MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|