Link to home
Start Free TrialLog in
Avatar of isaacr25
isaacr25

asked on

Help with update query

SQL Server 2000.
I have the following query which runs fine:

UPDATE MASTER55
  SET API__bNumber = t2."EMP ID", [Has__bAPI__bMatch__bRun__Q]='Yes'

FROM MASTER55 t1
JOIN [API].LaborWorkx_Live.dbo.vwCGHS_All_EmpList t2
  ON t1.SSN = right(t2.SSN, len(t2.SSN) - 1)
 AND t1.L__d__bName = t2."Last Name"
 AND t1.F__d__bName = t2."First Name"
 AND t1.mrREF_TO_MR Is null
 AND API__bNUMBER Is null
 AND [Has__bAPI__bMatch__bRun__Q] Is null

However, I need to change it to achieve the following. I need the field [Has__bAPI__bMatch__bRun__Q] to be set to Yes regardless of whether a successful match is made between the EMP ID and API__bNumber. This [Has__bAPI__bMatch__bRun__Q] field will be used to tell whether or not the query has ran for that particular record, so it needs to be set to Yes each time the query runs, whether its successful or not in finding a match. Please advise. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of SQL_SERVER_DBA
SQL_SERVER_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of isaacr25
isaacr25

ASKER

SQL SERVER DBA,
     I ran this code with 2 records, one where there was a matching API__bNumber, and one where there wasn't one. [Has__bAPI__bMatch__bRun__Q] was only updated in the record with the match. I need this field to be updated even if there is no match.
Please see my last post. Thanks.
Hello... anyone there?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial