• You were very helpful to me. I removed the two extra columns I don't need and ran cursor in a new window and now I have results. Thanks you.

    what worked

    use MiguelsApp

    DECLARE @DatabaseName varchar(max)

    DECLARE getDatabaseName CURSOR FOR

    SELECT name

    FROM sys.databases

    where name not in ('master', 'tempdb', 'model', 'msdb');

    OPEN getDatabaseName

    FETCH NEXT

    FROM getDatabaseName INTO @DatabaseName

    WHILE @@FETCH_STATUS = 0

    BEGIN

    print @DatabaseName

    FETCH NEXT FROM getDatabaseName

    INTO @DatabaseName

    END

    close getDatabaseName

    deallocate getDatabaseName