Avatar of Andy Green
Andy Green
Flag for United Kingdom of Great Britain and Northern Ireland asked on

How best to achived adding ad hoc rows to a table

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
ASP.NETMicrosoft SQL Server

Avatar of undefined
Last Comment
Andy Green

8/22/2022 - Mon
Pawan Kumar

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.
ASKER CERTIFIED SOLUTION
Andy Green

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Andy Green

ASKER
This was how I achieved this in the end. No other suitable replies.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23