Creating a SQL function

  
Hi,

I need to call the below function in a subsequent Advanced Query - how can I best create the function? Is it possible through the Outsystems front end or does it need to be written directly to the SQL server. I would greatly appreciate any advice you could pass on.

Many thanks,
Richard

CREATE FUNCTION dbo.Split ( @String VARCHAR(8000), @Delimiter NVARCHAR(1))
RETURNS @Tokens table
(
Token NVARCHAR(255)
)
AS
BEGIN
  WHILE (CHARINDEX(@Delimiter,@String)>0)
   BEGIN
    INSERT INTO @Tokens (Token) VALUES (LTRIM(RTRIM(SUBSTRING(@String,1,CHARINDEX(@Delimiter,@String)-1))))
    SET @String = SUBSTRING(@String,
    CHARINDEX(@Delimiter,@String)+LEN(@Delimiter),LEN(@String))
   END
INSERT INTO @Tokens (Token) VALUES (LTRIM(RTRIM(@String)))
RETURN
END
 
GO
Hi Richard,

The platform does not support this. You'll have to create it using the appropriate database tools. Be sure that the function is created in a way that the Outsystems database user can access it.
Actually the plataform does support this IF you provide the runtime database user the appropriate rights, which is not a good security policy, and that is why it's not on the runtime user's privileges to start with.

Anyway if your requirements don't include create functions that may have their code changed in time, the best approach is, as Kilian said, to do it with the appropriate database tools, preferably in the dbo schema of the plataform database.

Best regards,
PC