I need to make some adjustment to a store Procedure, more like the select statement:
@EmployeeNumber varchar(15)
select ID, EmployeeNumber, EmployeeName,
from EmployeeTable
where ID = @EmployeeNumber
Ok i have 4 tables
EmployeeTable, EmployeeAddress, EmployeeRequest, EmployeeLog
Now I only have JobStatus in EmployeeRequest table...
EmployeeTable
ID EmployeeNumber EmployeeName
1 001 Joe
2 002 Sam
3 003 Dia
EmployeeAddress
ID EmployeeNumber EmployeeName EmployeeAdress
1 001 Joe 1200 S. BLVD
3 003 Dia 0987 E. park dr.
EmployeerRequest
ID EmployeeNumber EmployeeName JobStatus
1 001 Joe Y
2 002 Sam N
3 003 Dia Y
EmployeeLog
ID EmployeeNumber EmployeeName
1 001 Joe
2 002 Sam
So i need to add Address_Status in the query
@EmployeeNumber varchar(15)
select ID, EmployeeNumber, EmployeeName, [red]Address_Status[/red]
from EmployeeTable
where ID = @EmployeeNumber
Address_Status logic...
[blue]If EmployeeNumber exists in EmployeerLog table (compare Employee Number coming from EmployeeTable ) and if Job_Status IS 'N' in EmployeerRequest then Address_Status is 'Has No Address' else 'Has Address'
If EmployeeNumber exists in EmployeerAddress table (compare Employee Number coming from EmployeeTable ) then Address_Status is 'Has Address' else ''Has No Address'[/blue]
So all this has to be compared checked and added in the above query... Both the above conditions has to be added in the above query... Any help is appreciated.
@EmployeeNumber varchar(15)
select ID, EmployeeNumber, EmployeeName,
from EmployeeTable
where ID = @EmployeeNumber
Ok i have 4 tables
EmployeeTable, EmployeeAddress, EmployeeRequest, EmployeeLog
Now I only have JobStatus in EmployeeRequest table...
EmployeeTable
ID EmployeeNumber EmployeeName
1 001 Joe
2 002 Sam
3 003 Dia
EmployeeAddress
ID EmployeeNumber EmployeeName EmployeeAdress
1 001 Joe 1200 S. BLVD
3 003 Dia 0987 E. park dr.
EmployeerRequest
ID EmployeeNumber EmployeeName JobStatus
1 001 Joe Y
2 002 Sam N
3 003 Dia Y
EmployeeLog
ID EmployeeNumber EmployeeName
1 001 Joe
2 002 Sam
So i need to add Address_Status in the query
@EmployeeNumber varchar(15)
select ID, EmployeeNumber, EmployeeName, [red]Address_Status[/red]
from EmployeeTable
where ID = @EmployeeNumber
Address_Status logic...
[blue]If EmployeeNumber exists in EmployeerLog table (compare Employee Number coming from EmployeeTable ) and if Job_Status IS 'N' in EmployeerRequest then Address_Status is 'Has No Address' else 'Has Address'
If EmployeeNumber exists in EmployeerAddress table (compare Employee Number coming from EmployeeTable ) then Address_Status is 'Has Address' else ''Has No Address'[/blue]
So all this has to be compared checked and added in the above query... Both the above conditions has to be added in the above query... Any help is appreciated.