Select DI.*, C.* from Table1 DI LEFT join Table2 C on dI.Key=C.Key ANd (Di.Status <16 OR Di.Status =36 OR DI.Status =40) AND (DI.UserID=@userID OR C.UserID=@UserID) where DI.Department = @Department
SELECT DI.*, C.* FROM...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)