Page 1 of 1

mysql_insert_id()

Posted: Fri Nov 26, 2004 3:22 am
by snicolas
Anybody knows of an equivalent of mysql_insert_id() in MSSQL?
I just inserted a record and need the current ID of this record.

Thx

S.

MAY BE LIKE THAT

Posted: Fri Nov 26, 2004 3:32 am
by snicolas
I just though of a way of doing it, but it might be a bit buggy...
By selecting the last id created, I get the right record number.

select top 1 ID from company order by ID desc

Trouble is if 2 person add a new record on the same time....

Anybody think of a different way?

Posted: Fri Nov 26, 2004 11:39 am
by timvw
doesn't have to be a problem if you use transactions.