devxlogo

Identity?

Identity?

Question:
I’m trying to get the Identity of records as I insert them into my database. I have tried: OrderID = DataConn.Execute(“SELECT @@IDENTITY FROM Orders”). But this returns a syntax errorat ‘@@IDENTITY’. I am using JScript with NT4 and MS Access.

Answer:
What you really want is to select the column name with the Identity property. So, if the column that has the identity property is called iFramis, you would ask for SELECT iFramis from Orders. @@identity might just give you the last integer used in the column.

create table junk (iid, identity (1,1))goinsert junk default valuesgoinsert junk default valuesgoselect iid from junkselect @@identity from junk

See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist