Table 1
Empaname empid Deptid
kumar 23 1
kumar 23 2
manu 45 3
manju 34 4
manju 34 5
manju 34 6
Table2
Empaname empid Deptid
kumar 23 1
manu 45 3
manju 34 5
Here i have 2 tables i am comparing two table values based on that i need to update the values int table 2
if exists(select Empid from empname=@strempname and Empid=@Intempid and DEptid<>@intdepID)
Begin
//here both Empname and Empid is matching and DeptID is not matching then do not do anything just return an value as 2
return 2
end
else
begin
//Update the record vales to an Temp Table
end
i am writing this Query, it is getting failed for that condition .
can any one help me out to write an Query for this
thanks