Parsing Keys

When you are writing stored procedures for use with CALUMO, the following function will help split apart the keys that CALUMO passes to you representing the datapoint that is being written back to.

CREATE FUNCTION [dbo].[fnSplitParameters]
(
    @inputstring Varchar(max),
    @delim varchar(10)
) returns @result TABLE (Value varchar(max))

AS

Begin
    Declare @temp as varchar(max)
    Declare @xml as xml

    Set @temp=('<x>' + replace(replace(@inputstring,'&','&amp;') ,@delim, '</x><x>') + '</x>' )

    Set @xml=Cast(@temp as xml)

    Insert Into @result

    Select N.value('.', 'varchar(10)') as value
    From @xml.nodes('x') as T(N)

    Return
End