/* * Description: Get a plastic web deal's BranchID by knowing it's MoversConnectID **/ createprocedure[dbo].[GetPlasticWebDealBranchID] @inMoversConnectIdbigint, @outBranchIDvarchar(5)output as setnocounton
set@outBranchID=isnull(( selecttop1-- There should only be one such record, but there is no guarantee. Branch.BranchID fromPlasticWebDeal innerjoinBranchonBranch.BranchPriKey=PlasticWebDeal.BranchPriKey wherePlasticWebDeal.MoversConnectFID=@inMoversConnectId ),'') GO GRANTEXECUTEON[dbo].[GetPlasticWebDealBranchID]TO[MssExec] GO