?
Solved

Insert record for user and update all duplicates

Posted on 2009-04-03
3
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 53

Accepted Solution

by:
Ryan Chong earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

777 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