UFN_DEPOSITREPORT_PARSEDEPOSITLIST
Function to turn pipe-delimited list into table
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@DEPOSITLIST | nvarchar(max) | IN |
Definition
Copy
create function dbo.UFN_DEPOSITREPORT_PARSEDEPOSITLIST(@DEPOSITLIST nvarchar(max))
returns @ALLDEPOSITS table (DEPOSITID uniqueidentifier)
with execute as caller
as begin
declare @DEPOSITID nvarchar(36)
declare @POSITION int
set @DEPOSITLIST = ltrim(rtrim(@DEPOSITLIST)) + '|'
set @POSITION = charindex('|', @DEPOSITLIST, 1)
while @POSITION > 0
begin
set @DEPOSITID = LTRIM(RTRIM(LEFT(@DEPOSITLIST, @POSITION - 1)))
if @DEPOSITID <> ''
begin
insert into @ALLDEPOSITS (DEPOSITID)
values (convert(uniqueidentifier, @DEPOSITID))
end
set @DEPOSITLIST = right(@DEPOSITLIST, len(@DEPOSITLIST) - @POSITION)
set @POSITION = charindex('|', @DEPOSITLIST, 1)
end
return
end