troubleshooting Question

Help with T SQL statement

Avatar of simonsjd
simonsjdFlag for United Kingdom of Great Britain and Northern Ireland asked on
* T-SQLMicrosoft SQL Server
8 Comments1 Solution91 ViewsLast Modified:
I have very limited Microsoft SQL experience but need an efficient way to do this.

field1 field2 field3

field1 field2 field4

I want to work through table1 - first to last
check table2 for match on table1.field1 = table2.field1 and table2.field4 = 'Y'
if no match
      create new record in table2
if match and table1.field2 <> table2.field2
      update table2.field4
      create new record in table2

      Any help appreciated
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros