November 5, 2014 at 2:18 pm
I received a request to create a stored proc with following:
I have a view with the following columns
(table1 - AppCode, AgencyID, CompnyID, CustCode, CustVal)
I have a proc that will take the following parameters and return all matching rows (AppCode, AgencyID, CompnyID, CustCode(optional))
The trick: Any customcode with the CompnyID should override the AgencyID parameter.
Can anyone point me in the right direction with this? Any help would be greatly appreciated. Thx!
November 5, 2014 at 3:56 pm
I think you need something like this:
Create procedure ProcedureName @AppCode int, @AgencyID int, @CompnyID int, @CustCode int=null
as
select @AgencyID = coalesce(@CustCode,@AgencyID)
select AppCode, AgencyID, CompnyID, CustCode, CustVal
from table1
where appcode = @appcode and agencyid = @agencyID and CompnyID = @CompnyID
November 6, 2014 at 12:32 pm
Thank you very much Adam!
November 6, 2014 at 12:41 pm
Glad it helped you out.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply