About IDENTITY constraint in SQL

Results 1 to 2 of 2

Thread: About IDENTITY constraint in SQL

  1. #1
    Join Date
    Dec 1969

    Default About IDENTITY constraint in SQL

    Hi<BR><BR>I have a SQL table &#039A&#039 where &#039col1&#039 is a primary column with IDENTITY constraint. This &#039col1&#039 is a foreign key to another table &#039B&#039. So in my VB code I am begining a transaction to insert a row in table A and table B. After a row is inserted into the table A, a autonumber is automatically given to that row. Now how will I get that Number in &#039col1&#039 so that I can use it for insert statement in table &#039B&#039

  2. #2
    Brad Kingsley Guest

    Default RE: About IDENTITY constraint in SQL

    SELECT @@IDENTITY right after the insert statement to get the value of the identity field. Ideally you would wrap this into a single SP to speed the transaction and ease coding.<BR><BR>-Brad Kingsley, MCP - NT, IIS4<BR>Reliable Windows NT Web Hosting<BR>ORCS Web, Inc - http://www.ORCSWeb.com<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts