Identify columns


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Identify columns

  1. #1
    M. Spray Guest

    Identify columns


    ....Moving over from ORACLE where the sequence object could be
    called directly to populate the PK's...

    Three issues:

    issue one:

    What is the best method in SQL 2000 to handle master / detail relationships
    where primary keys are abstract and the detail has an FK into the Master
    (don't really care if there might be gaps).

    The transaction for posting the data from the application requires:

    Populate master, detail
    Master record be posted,
    retreive of IDENT_CURRENT('Master')
    fill in detail cursor FK,
    Detail record(s) post
    Share on Google+

  2. #2
    Rob Vieira Guest

    Re: Identify columns

    For issue one (which is really the only issue of yours I see in this post),
    it really depends. The typical solution is to use an IDENTITY column on the
    Master, do that insert first, then reference the newly inserted identity
    value in the child records.

    The rough scenario is:

    Insert into master (one row)
    Retrieve identity value using @@IDENTITY (or it's sibling functions if
    you're using SQL Server 2000)
    Use the retrieved identity value in the referencing column for the records
    you insert in the child table.


    --
    Rob Vieira MCSD, MCT, MCDBA
    www.ProfessionalSQL.com

    "M. Spray" <spraym@attglobal.net> wrote in message
    news:3a6e5dae$1@news.devx.com...
    >
    > ...Moving over from ORACLE where the sequence object could be
    > called directly to populate the PK's...
    >
    > Three issues:
    >
    > issue one:
    >
    > What is the best method in SQL 2000 to handle master / detail

    relationships
    > where primary keys are abstract and the detail has an FK into the Master
    > (don't really care if there might be gaps).
    >
    > The transaction for posting the data from the application requires:
    >
    > Populate master, detail
    > Master record be posted,
    > retreive of IDENT_CURRENT('Master')
    > fill in detail cursor FK,
    > Detail record(s) post



    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center