April 12, 2010 at 10:24 pm
This is my sample data.
EmpidDeptidSalary
123000
223500
445000
356000
667000
834000
926000
1068000
Malleswarareddy
I.T.Analyst
MCITP(70-451)
April 12, 2010 at 10:58 pm
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..
April 12, 2010 at 11:08 pm
ok,
I want Particular departmant only.Just i copy and pasted this.next time i will post the sample data with proper format.not just for single update statement.It need to verify if that employee belongs to particular department and then update salary when his salary less than thousand else put same.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
April 12, 2010 at 11:29 pm
Still very very unclear buddy.. can u post some sample query or visual samples of your requirement in accordance with the sample data i posted??
April 12, 2010 at 11:47 pm
Basiclly, something like this:
update dbo.Employee set
Salary = Salary * 1.2 -- Increase Salary by 20%
where
DeptID = 3
and Salary < 1000.00
April 12, 2010 at 11:53 pm
Lynn Pettis (4/12/2010)
Basiclly
:-D, Lynnn, thats very basic , isnt it.. 😛 ... wonder how the OP missed filtering the rows directly by WHERE clause..
April 12, 2010 at 11:59 pm
COldCoffee (4/12/2010)
Lynn Pettis (4/12/2010)
Basiclly:-D, Lynnn, thats very basic , isnt it.. 😛 ... wonder how the OP missed filtering the rows directly by WHERE clause..
Thinking procedurely instead of in a set-based manner. Asking what I need to do to a row instead of a column.
April 13, 2010 at 12:39 am
Oh yes.. 🙂
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply