Scalar-valued Functions [dbo].[CollectionNext]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@xxmlmax
@iint4
SQL Script
CREATE FUNCTION [dbo].[CollectionNext](@x XML, @i int)
returns int
BEGIN
return (
select min(val) from (select T.c.value('@key', 'int') val
    FROM @x.nodes('collection/item') T(c)) a
   WHERE val > @i
)
END;
GO
Uses