Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 retrieving the ID field
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

126 Posts

Posted - 07/18/2006 :  15:48:34  Show Profile  Reply with Quote
I'm sure my problem is not unique, but I am having a hard time thinking of a way to solve it so here it is:
I have a VB form with some fields on it, which are used to create a new entry in one of my SQL tables. The design kinda goes like this: all fields are mandatory and in addition to that the primary field (fid) in the table is the identity field which self increments.
So the question is: how do I retrieve the id value from the fid field for my newly created entry? To make things harder, it is possible that two entries can have ALL fields identical.


Almighty SQL Goddess

38200 Posts

Posted - 07/18/2006 :  15:54:13  Show Profile  Visit tkizer's Homepage  Reply with Quote
You need to capture the value of SCOPE_IDENTITY() directly after the insert is performed.

DECLARE @i int



Tara Kizer

Edited by - tkizer on 07/18/2006 15:55:12
Go to Top of Page

Posting Yak Master

126 Posts

Posted - 07/18/2006 :  17:33:32  Show Profile  Reply with Quote
thanx. I found the article on msdn. thanx anyway
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000