I wrote this query:
SELECT DISTINCT EMER_EmployeeID FROM (SELECT [EMER_EmployeeID], [EMER_Employee_StatusDateS] FROM [dbo].[EmployeeERP] AS B WHERE [EMER_ClassCode] NOT IN ( 1, 2, 3, 5, 6, 8 ) AND [EMER_Employee_StatusCode] NOT IN ( 3, 4, 5, 6, 68, 0, 1, 9 )) AS t INNER JOIN [dbo].[MonthlySalary] AS K ON K.MS_EmployeeID = T.EMER_EmployeeID WHERE K.MS_Month > 2 + ( CAST(CAST(RIGHT('0' + RTRIM(MONTH([EMER_Employee_StatusDateS])), 2) AS FLOAT) AS INT) ) That give me a list of ID'S.
I have another table - call her TB:
TE_EmployeeID TE_IsCheck I wrote this to make all TE_IsCheck Zero: Update TB set [TE_IsCheck]= 0
Now, I want to update to 1 the field TE_IsCheck according to list in the 'Big' Query. How can I do that? Thank you!
2 + ( CAST(CAST(RIGHT('0' + RTRIM(MONTH([EMER_Employee_StatusDateS])), 2) AS FLOAT) AS INT) )seems completely unnecessarily complex. Why not2 + MONTH([EMER_Employee_StatusDateS])?2 + MONTH([EMER_Employee_StatusDateS])- It should do the same thing as your convoluted expression. Trimmng integers and adding leading zeroes and casting to float then int isn't going to change the result.