Mate, if u update the salary > 5000, it will constantly update everywhere. I dont think u need to search for values > 5000 in every department and update.. just update salary > 5000 to your value...
And , your post is seriously bad.. there was no explanantion on what to do except from the "Description" u had given in the thread.. please post a proper question , the DDLs , desired result... Sorry mate, a poster who has 794 posts should not be asking such a shabby question mate 🙁
For those who are attempting to create a query for the poster, here are the DDLs..
IF OBJECT_ID('TEMPDB..#SALARY_DETAILS') IS NOT NULL
DROP TABLE #SALARY_DETAILS
CREATE TABLE #SALARY_DETAILS
(
EMP_ID INT,
DEP_ID INT,
SALARY INT
)
INSERT INTO #SALARY_DETAILS
SELECT 1,1, 6000
UNION ALL
SELECT 2,2, 2999
UNION ALL
SELECT 3,2, 6000
UNION ALL
SELECT 4,2, 5001
UNION ALL
SELECT 5,3, 3500
UNION ALL
SELECT 6,3, 5002
SELECT
EMP_ID,
DEP_ID,
SALARY
FROM
#SALARY_DETAILS
Cheers..