MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » September 2012

Re: How could I set up a SQL script to insert records into a without duplicates



fixed

Darryl,

Haven't been following this thread too closely but I think that *maybe* the
following code could help:

Create view Qtemp.Insert_dta as
With t1 as(
select q1.*, rrn(q1) as rrn_q1 from qtemp.quote q1 )
Select t1.* from t1
where not exists(
Select 1 from qtemp.quote q2
where rrn(q2) > t1.rrn_q1
AND t1.qtvend = q2.qtvend
and (
(t1.qtdtef between q2.qtdtef and q2.qtdtex) OR
(t1.QTDTEX between q2.qtdtef and q2.qtdtex)
)
)

**********
It should be a little slow. Having the appropriate indexes should help a
lot.

Just INSERT the columns you need.


HTH,
Luis Rodriguez
IBM Certified Systems Expert — eServer i5 iSeries





Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact