help help help(sql) :(

mjayanatha

Well-known member
  • Jan 9, 2008
    28,378
    1,885
    113
    යන එන මං නැහැ

    CREATE FUNCTION [dbo].[fnParseStringTSQL] (@string NVARCHAR(MAX),@separator NCHAR(1))
    RETURNS @parsedString TABLE (stdmarks NVARCHAR(MAX))
    AS
    BEGIN
    DECLARE @position int
    SET @position = 1
    SET @string = @string + @separator
    WHILE charindex(@separator,@string,@position) <> 0
    BEGIN
    INSERT into @parsedString
    SELECT substring(@string, @position, charindex(@separator,@string,@position) - @position)
    SET @position = charindex(@separator,@string,@position) + 1
    END
    RETURN
    END
    go

    select t.stdId, p.stdmarks
    from tba t
    cross apply [dbo].[fnParseStringTSQL](t.stdmarks,',') p



    drop function [dbo].[fnParseStringTSQL]




    :nerd: pana giya machan
     
    Last edited:

    ad.hasareli

    Well-known member
  • Mar 27, 2010
    5,264
    580
    113
    දකුනේ කොල්ලෙක්

    CREATE FUNCTION [dbo].[fnParseStringTSQL] (@string NVARCHAR(MAX),@separator NCHAR(1))
    RETURNS @parsedString TABLE (stdmarks NVARCHAR(MAX))
    AS
    BEGIN
    DECLARE @position int
    SET @position = 1
    SET @string = @string + @separator
    WHILE charindex(@separator,@string,@position) <> 0
    BEGIN
    INSERT into @parsedString
    SELECT substring(@string, @position, charindex(@separator,@string,@position) - @position)
    SET @position = charindex(@separator,@string,@position) + 1
    END
    RETURN
    END
    go

    select t.stdId, p.stdmarks
    from tba t
    cross apply [dbo].[fnParseStringTSQL](t.stdmarks,',') p



    drop function [dbo].[fnParseStringTSQL]




    :nerd: pana giya machan


    Machan wede hari.... thnxxxxxxxx thanxxxxx thanxxxxxxx a lot machan :):)
     

    hansa1018

    Member
    Sep 9, 2008
    13,509
    1,621
    0
    Colombo

    CREATE FUNCTION [dbo].[fnParseStringTSQL] (@string NVARCHAR(MAX),@separator NCHAR(1))
    RETURNS @parsedString TABLE (stdmarks NVARCHAR(MAX))
    AS
    BEGIN
    DECLARE @position int
    SET @position = 1
    SET @string = @string + @separator
    WHILE charindex(@separator,@string,@position) <> 0
    BEGIN
    INSERT into @parsedString
    SELECT substring(@string, @position, charindex(@separator,@string,@position) - @position)
    SET @position = charindex(@separator,@string,@position) + 1
    END
    RETURN
    END
    go

    select t.stdId, p.stdmarks
    from tba t
    cross apply [dbo].[fnParseStringTSQL](t.stdmarks,',') p



    drop function [dbo].[fnParseStringTSQL]




    :nerd: pana giya machan


    elaazz...................