Solved

Insert record for user and update all duplicates

Posted on 2009-04-03
3
212 Views
Last Modified: 2012-05-06
I want to insert a record for a user but update a field on all other record with that exact email address.
I am adding a column in the DB for duplicate.
SQL = "INSERT INTO homeFormUsers (firstName,lastName,emailAdd,interestedIn,datesubmitted)"

SQL = SQL & "VALUES ('" & strFname & "','" & strLname & "','" & strEmailAdd & "','" & strIntersted & "','" & strCurrDateTime & "') "

Open in new window

0
Comment
Question by:pGustafson
3 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 24060464
need a trigger:

create trigger mytrigger on homeFormUsers
for insert
as
begin
update h
somefield = somevalue
from homeFormUsers  h
join inserted i on h.emailAdd = i.emailadd

end
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 24060468
>>but update a field on all other record with that exact email address

What field is that? you can try:

...

SQL = "Update homeFormUsers Set yourField =yourValue Where emailAdd = '" & strEmailAdd & "' "

conn.execute SQL

SQL = "INSERT INTO homeFormUsers (firstName,lastName,emailAdd,interestedIn,datesubmitted)"
SQL = SQL & "VALUES ('" & strFname & "','" & strLname & "','" & strEmailAdd & "','" & strIntersted & "','" & strCurrDateTime & "') "

conn.execute SQL

....


get the idea?
0
 

Author Closing Comment

by:pGustafson
ID: 31566260
That worked, thank you!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now