Solved

Insert record for user and update all duplicates

Posted on 2009-04-03
3
231 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 50

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

786 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