Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lols
Posting Yak Master
174 Posts |
Posted - 2007-11-21 : 04:16:06
|
Hi,I have four tables:Employee EmpDetail EmpPbirth EmpErlrempid empid empid empidstate fnm bplace coinfo lnm bcity town empdtid emppobid emperlrid I have the following stored procCREATE PROCEDURE [dbo].[BringEmployeeData]@EId int,@language intASSELECT distinct emp.empid ,emp.state, empdet.fnm, empdet.lnm,empPob.bplace, empPob.bcity, emperlr.coinfo, emperlr.townFROM Employee as empINNER JOIN EmpDetail as empdet ON emp.empid = empdet.empid LEFT OUTER JOIN EmpPbirth as empPob ON emp.empid = empPob.empidLEFT OUTER JOIN EmpErlr as emperlr ON emp.empid = emperlr.empid WHERE emp.empid = @EIdand empdet.lang = @language and empPob.lang = @languageand emperlr.lang = @language The data comes well when all the four tables are filled. However whenever there is no data in empPob and emperlr, this condition fails--and empPob.lang = @language--and emperlr.lang = @languageand no data appears. I cannot remove the condition as then data will be returned in multiple lang which is not desired.What do i do to check the condition empPob.lang = @language if there is data and avoid it if there is no datathanks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-21 : 04:23:40
|
[code]SELECT DISTINCT emp.empid ,emp.state, empdet.fnm, empdet.lnm, empPob.bplace, empPob.bcity, emperlr.coinfo, emperlr.townFROM Employee AS empINNER JOIN EmpDetail AS empdet ON emp.empid = empdet.empidLEFT OUTER JOIN EmpPbirth AS empPob ON emp.empid = empPob.empid AND empPob.lang = @languageLEFT OUTER JOIN EmpErlr AS emperlr ON emp.empid = emperlr.empid AND emperlr.lang = @language WHERE emp.empid = @EIdAND empdet.lang = @language[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
lols
Posting Yak Master
174 Posts |
Posted - 2007-11-21 : 04:31:48
|
| thank you my friend |
 |
|
|
|
|
|
|
|