INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Create Unique Order # with Order # + Sequence #

Create Unique Order # with Order # + Sequence #

(OP)
I have an order table and lab results table. The field I am joining the tables on is OrderID, but it's not unique because if the patient is given multiple tests, each test has the same OrderID. I need to update some tests but not all of them, so I need to get to the test level to evaluate each record. I want to create a new OrderId by using the existing OrderID(ex. PRO12345) and adding a sequence number at the end(ex. PRO12345-1, PRO12345-2, etc) for each test. Then I want to add this new OrderID to my order and lab result tables to use as a join for my update. How do I do this??

RE: Create Unique Order # with Order # + Sequence #

CREATE TABLE OrderLabBridgeTable (
OrderLabBridgeKey integer,
OrderID it's type and size,
OrderSeq integer,
LabResultsID it's type and size);

Then write a TRANSACT-SQL cursor to populate the table. I'll add an example later. Then write a trigger to keep the bridge table in sync.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


RE: Create Unique Order # with Order # + Sequence #

(OP)
Thanks John. Please add the example of the cursor to populate the table. I'm handle reporting but I'm not a SQL wizard. I usually work with DBA's to handle things like this. I appreciate the suggestion...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close