Solved

Insert record for user and update all duplicates

Posted on 2009-04-03
3
250 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 52

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

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 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