Results 1 to 2 of 2

Thread: Return GUID value Like @@IDENTITY

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Return GUID value Like @@IDENTITY

    Is there a way to return the equivalent of @@IDENTITY using a GUID?

    I need to insert data into a database in a parent/child format.

    I insert the parent information into the parent table like this
    Code:
    Parent Table
    PID (GUID) PK
    ParentName
    
    INSERT INTO tableName VALUES(newid(), '" & strParentName & "')
    Then I need to insert the child information into the childs table something like this
    Code:
    Child Table
    CID (GUID) PK
    PID (GUID) FK references ParentTable.PID
    ChildName
    
    INSERT INTO tableName VALUES(newid(), get GUID that was inserted in ParentTable.PID field, '" & childName & "')
    any ideas?
    Last edited by Memnoch1207; Oct 23rd, 2003 at 01:53 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you are using SQL then you can do both writes in one stored procedure or use a trigger. If you want to do it in the app then you'd have to retrieve the ID inbetween calls. Will one of those work for you?
    Last edited by Edneeis; Oct 23rd, 2003 at 02:27 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width