All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[customrefproc] (@iPersonId as int, @iOppoId as int) as begin declare @nvchPersInitials as nvarchar(2), @nvchRegionCode as nvarchar(2), -- I'm assuming it's always a 2 letter string. Alter to suit needs @iCompanyId as int, @iCustomId as int, @nvchCustomCode as nvarchar(15) if exists (select * from person where pers_personid = isnull(@iPersonId, 0) and pers_deleted is null) -- Does the person exist? begin select @nvchPersInitials = isnull(left('Pers_FirstName', 1), '-') + isnull(left('pers_lastname', 1), '-') -- If an initial isn't found it will replace it with a - if exists (select * from opportunity where oppo_opportunityid = isnull(@iOppoId, 0) and oppo_deleted is null) -- Does the oppo exist? begin select @iCompanyId = isnull(oppo_primarycompanyid, 0) from Opportunity where oppo_opportunityid = @iOppoId and oppo_deleted is null if @iCompanyId > 0 -- Did we get a company ID back? begin -- I'll assume a one to one relationship between soci and company select @nvchRegionCode = soci_code from company join SocialWorkRegion on soci_socialworkregionid = comp_socialworkregionid where comp_companyid = @iCompanyId and comp_deleted is null end else begin -- No company ID found return 4 end -- Now we have all the bits we need the next ID number in the series by calling the Sage CRM sp to generate the next ID properly exec @iCustomId = eware_get_identity_id 'CustomRefs' if isnull(@iCustomId, 0) > 0 begin -- This is the line that will give you your code in the form XX-YY-NNNNN select @nvchCustomCode = @nvchPersInitials + '-' + @nvchRegionCode + '-' + right('0000' + cast(@iCustomId as nvarchar(5)), 5) end else begin -- Didn't get an ID back from the internal sp return 3 end end else begin -- Oportunity doesn't exist or one wasn't passed in return 2 end end else begin -- Person doesn't exist or an ID wasn't passed in return 1 end end
|Calculate the interval of days between a discharge date and a subsequent admission date for the same Medical Record #||3||35|
|Need help with a query||3||35|
|Parsing the XML data to SQL Server||4||39|
|SQL Server 2012 express||24||21|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
22 Experts available now in Live!