Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Practice to Avoid Duplicates
Message
 
 
To
28/08/2008 15:14:08
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01342767
Message ID:
01342775
Views:
9
>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 && We don't have this record yet
   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
Previous
Reply
Map
View

Click here to load this message in the networking platform