I'm using sql server 2005, I created a customer table and set the customer_id as an uniqueidentifier that is a NEWSEQUENTIALID()...when a user is created I want to obtain the last customer_id so that I can insert it in another table that has a one to many relationship with the customer table. Please help...how do i do this?.
Thanx
YOu can issue this query after you insert: SELECT scope_identity();
and it will give you back your last inserted record. Take a look at this link for more details.
http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
bdotjones:
I thought the SELECT scope_identity() on worked for identity fields does it also work for uniqueidentifier fields?
Try this for more info. Hope this helps.
http://sqljunkies.com/Article/4067A1B1-C31C-4EAF-86C3-80513451FC03.scuk
No comments:
Post a Comment