Scalar-valued Functions [dbo].[GetCollection_int]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@xxmlmax
@iint4
SQL Script
CREATE FUNCTION [dbo].[GetCollection_int]
( @x XML, @i int ) RETURNS int
BEGIN
  RETURN (SELECT TOP 1 T.c.value('val[1]', 'int')
   FROM @x.nodes('collection/item') T(c) WHERE T.c.value('@key', 'int') = @i)
END
GO
Uses