I have SQL server function as below and is called wthin a view, can we implement similar logic in a function in Teradata? If not then is there any alternative?
CREATE FUNCTION [dbo].[SplitStrings] (
RETURNS @T TABLE (Value INT, ID INT)
--SET @String = @String + ';'
SET @String = @String + @delimiter
declare @Pos int
declare @Value int
declare @s varchar(20)
declare @long int
set @long = 1
WHILE len(@String) <> 0
set @Pos = charindex(@delimiter,@String)
IF @Pos=0 BREAK
set @s = substring(@String,1,@Pos-1)
-- insure we actually have a value before we insert in the table
if ltrim(rtrim(@s)) <> ''
INSERT @T (Value, ID) VALUES (cast(@s as int), @long)
SET @String = substring(@String,@Pos+1,8000)
SET @long = @long+1
Solved! Go to Solution.
That's a handy function! Functions like this are documented in the Teradata SQL Reference: Functions and Operators. In general, if you can't find another way to convert a SQL (or PL/SQL) function to Teradata, check out