Here's my SQL: - INSERT INTO HFIAAREF
-
(Select Distinct PolSt, PolNo, PolCn, PolYr, PstDa@, 0, 0, 0, 0, Compny, AgHd, AgBr, AgDv, AgID, 0, 0, 0, BlRatB, AlRatB, BlRatC,AlRatC, ' ', ' ', ' ', ' ', 'HFIAAPF12 ', 'SUSMST ',Current_Timestamp, User, RegEmr, DckDa@, Status, RateSw, Condo, FloodZ, ZoneNo, OccCod, NumFlr, AlAmtB, BasTyp,EleDif, CovReq, TBAI, TCAI, BsFldE, RskRat, PRPRskRat,Elev, Coalesce(PsbMeEncl, ''), Coalesce(PsbVCrawl, ''),ObsInd, InsInd, OrCo@, NewCst, CStID, CComID,Coalesce(CmFrCC, 0), Coalesce(CmFrCY, 0), Coalesce(CmFrCM, 0),Coalesce(CmFrCD, 0), Fil1Date, SUBSTRING(FIL2ALPH,9,1)
-
FROM SUSMST
-
JOIN PPOLADDL on (PolSt = PolPolSt and PolNo = PolPolNo and PolCn = PolPolCn and PolYr = PolPolYr)
-
LEFT OUTER JOIN PSUBMIT on (PolSt = PsbPolSt and PolNo = PsbPolNo and PolCn = PsbPolCn and PolYr = PsbPolYr)
-
LEFT OUTER JOIN CUMST on (CStID = CmSt# and CComID = CmID#)
-
WHERE PstDa@ >= 20131001 and DckDa@ <> 0 and ((Fil1Date > '2012-07-06') or (substring(FIL2ALPH,9,1) = 'Y')));
My issue is I do not want to insert the record into HFIAAREF if POLST, POLNO, POLCN and POLYR already exist in HFIAAREF. Any ideas?
4 1366
Please use code tags when posting code or formatted data.
Create a unique index on those fields and that will prevent someone from inserting duplicates.
@Rabbit
Will that not cause the insert to error when the duplicate is attempted? Please excuse my ignorance as this is a bit more complex SQL than I'm used to writing
Yes, it throws an error. As it should, it's the only 100% way of knowing you can never insert a duplicate.
Luuk 1,047
Expert 1GB
Google found the answer on how to do a 'INSERT IGNORE' (MySQL code) in MSSQL
the link is here Sign in to post your reply or Sign up for a free account.
Similar topics
by: Elijah Bailey |
last post by:
I want to sort a set of records using STL's sort() function,
but dont see an easy way to do it.
I have a
char *data;
which has size mn bytes where m is size of the record and
n is the...
|
by: authorking |
last post by:
I use the following code to insert a data record in to a datatable of an
access database.But every time I execute the command, there will rise an
exception and the insert operation can't be...
|
by: Andrew Bourne |
last post by:
I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records
user1 file1...
|
by: robecflo |
last post by:
Hi Forum, i have a problem, hope somebody can give me ideas. I'm
developing with windows forms and vb.net, and oracle as a database. At
this moment i have a table called amortizaciones, this table...
|
by: sparty1022 |
last post by:
we are constructing a (sql 2005) database on an FTP server where we will need
to insert records into the tables. At this point our ftp scripts will allow
us to upload/download documents/file from...
|
by: Hennie |
last post by:
Hi
Is it possible to insert records using the Footer row in a Gridview? I can
do it with a datagrid in VS2003, but the same code in VS2005 give me an error:
The code is:
Dim strOperatorID As...
|
by: David |
last post by:
Hi,
I have a MySQL database linked to an MS Access front-end.
I have an app which works fine with the local copy of the Access DB,
but when run with the linked tables for MySQL, it fails.
...
|
by: .Net Sports |
last post by:
I'm trying to insert records into an sql database coming from a page
using the request
..form method. The table "general" has a primary key 'geid .' I get the
following error:
Cannot insert the...
|
by: ramprakashjava |
last post by:
hi,
i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz..
...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |