mysql_insert_id()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

mysql_insert_id()

Post 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.
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

MAY BE LIKE THAT

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

doesn't have to be a problem if you use transactions.
Post Reply