SELECT name,recovery_model_desc AS Recovery_model
FROM sys.databases
WHERE name NOT IN ('model','master','tempdb','msdb')
ORDER BY recovery_model_desc, name
SELECT *, DB_NAME() as [DBase] FROM _YearOffset;
[ name ] [ Recovery_model ] [ _YearOffset ]
DECLARE @DBD TABLE ( [Name] VARCHAR(100), [Recovery Model] INT, [Offset] INT)
DECLARE @N NVARCHAR(100), @R INT, @F INT
DECLARE @Q NVARCHAR(100), @P NVARCHAR(100) = '@FF INT OUTPUT'
DECLARE DB CURSOR FOR
SELECT [name], [recovery_model]
FROM sys.databases
WHERE owner_sid <> 0x01
OPEN DB
FETCH NEXT FROM DB INTO @N, @R
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Q = 'SELECT @FF = Offset FROM ' + @N + '.[dbo].[_YearOffset]'
BEGIN TRY
EXECUTE sp_executesql @Q, @P, @FF = @F OUTPUT
END TRY
BEGIN CATCH
SET @N = @N + ' Not 1C'
SET @F = NULL
END CATCH
INSERT @DBD VALUES (@N, @R, @F)
FETCH NEXT FROM DB INTO @N, @R
END
CLOSE DB
DEALLOCATE DB
SELECT * FROM @DBD
GO