UFN_PDACCOUNTSTRUCTURE_DEFINEMASK2
Returns the account string format.
Return
Return Type |
---|
nvarchar(100) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_PDACCOUNTSTRUCTURE_DEFINEMASK2
(
@ID uniqueidentifier
)
returns nvarchar(100)
with execute as caller
as begin
declare @ACCTFORMAT nvarchar(101)
select @ACCTFORMAT = (select replicate('A',LENGTH) + case SEPARATORCODE when 6 then '' else left(SEPARATOR,1) end
from dbo.PDACCOUNTSTRUCTURE where PDACCOUNTSYSTEMID = @ID
order by SEQUENCE
for XML PATH(''))
--only delete last character if it is a separator (SeparatorCode 6 = no separator)
if (select top 1 SEPARATORCODE from dbo.PDACCOUNTSTRUCTURE where PDACCOUNTSYSTEMID = @ID order by SEQUENCE desc) != 6
set @ACCTFORMAT = left(@ACCTFORMAT,len(@ACCTFORMAT)-1)
return @ACCTFORMAT
end