>I am using SPT to create a table for a report. Initially I find a list of assemblies that match a certain job number. This I scan through each assy breaking them down to detail parts. This may take several sub scans for assemblies of assemblies. Each of these details is written to a temporary table. Now my problem is some assemblies have common parts. What is the best way to make sure my insert sql statements only write one record per detail number?
You can always check your table before trying to INSERT, e.g.
select ID from myTable where exists (select 1 from myTable where myCommonPart = )
if _tally = 0
insert
else
update
endif
And in SQL Server
IF NOT EXISTS (select 1 from myTable where myPart = "Something")
INSERT ...
Actually, may be you can create this as a Stored Procedure and do all the checks inside.
If it's not broken, fix it until it is.
My Blog