• stook (11/28/2014)


    if the cursor is not working then try the insensitive cursor. Without cursor - you mean something like this?

    declare @dbname nvarchar(255)='', @found bit=1

    while @found=1 begin

    set @found=0

    select top 1 @dbname=name,@found=1 from master..sysdatabases where name>@dbname and name like '%tst%' order by name

    if @found=1 begin

    print @dbname

    end

    end

    To be sure, that's just another form of a "cursor".

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)