?
Solved

Not updating the records after query

Posted on 2011-05-10
8
Medium Priority
?
215 Views
Last Modified: 2012-05-11
nothing is updated where they should.  Can see why is that so?  Because I know there are 58 records in Doctors where perID is null but they're still null.  Thank you.
update Doctors
set personID = p.personID
from dbo.person p
where Doctors.lastname = p.Employee_Last_Name 
and Doctors.First_Name = p.Employee_First_Name 
and Doctors.MiddleName = p.Employee_Middle_Name
and Doctors.personID is null

Open in new window

0
Comment
Question by:lapucca
8 Comments
 
LVL 9

Expert Comment

by:gdupadhyay
ID: 35734768
Can you please post the table structure for doctor and person?
0
 
LVL 9

Expert Comment

by:gdupadhyay
ID: 35734799
I have tested, your sql statement is correct.
Please check the table structure and datatype.

0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35735021
try this

update Doctors
set personID =
(
 Select personID From dbo.person p
where Doctors.lastname = p.Employee_Last_Name
and Doctors.First_Name = p.Employee_First_Name
and Doctors.MiddleName = p.Employee_Middle_Name
)
Where Doctors.personID is null
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 39

Accepted Solution

by:
appari earned 2000 total points
ID: 35735041
check my comment in your previous question, seems you closed the same time i posted.

http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_27030427.html?cid=748#35734418
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35735363
In addition to what @appari suggested on your other thread, do any of the JOIN columns (lastname, firstname, middleinitial) contain null values? Because those could cause the match to fail. ie a null doesn't equal anything. even another null.
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35736130
Please make sure there is no string 'NULL' instead NULL
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35739343
>> Please make sure there is no string 'NULL' instead NULL << 
Huh?
0
 

Author Closing Comment

by:lapucca
ID: 35742411
Thanks everyone for your input.  Apparently the problem is not this.  The records were never inserted.  Apparently I got an error from insertion before.  I have a new question for this.  Please post your answer there, thank you.
ID: 27032964
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

807 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