We help IT Professionals succeed at work.

How best to achived adding ad hoc rows to a table

114 Views
Last Modified: 2017-12-10
Hi All

I have a small section of an app that allows users to add parts to a job, so I have several tables a Job Table, a Part Table and a Job_Part table that links jobs to parts.

There is a requirement to add ad hoc items not in the parts table like consumables for example, and I can't figure out the best way to do it. The data has to end up in the Job_Part table, and I don't really want to add to the Part table and have to generate a part No.

The row would be effectively orphaned in the part_Job table. The app is not big so some  leeway on strict performance design

Does anyone have an idea on how to best achieve this?

Andy
Comment
Watch Question

Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
You can use T-SQL for that. There are multiple ways for this like IF EXISTS, NOT EXISTS , LEFT JOIN etc..
Could you please show some sample data and the expected output you need.
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
This was how I achieved this in the end. No other suitable replies.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions