A special querry

  • How i can get the number of time that a specific string appear in each register of my DB using T-SQL.

    These strings are in a field separated between then by white spaces and comma, ex.:" 001, 002, 003, 001, 007, 001, 002, etc"

  • Something like this.

    Could put it in a function.

    declare @i int, @j-2 int, @end int

    select @i = 1, @j-2 = 0, @end = 0

    while @end = 0

    begin

    select @i = charindex(@i+1,',' + @STR + ',',',001,')

    select @j-2 = @j-2 + 1

    if @i = 0

    select @end = 1

    end


    Cursors never.
    DTS - only when needed and never to control.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply