This will set all databases on the local system with the specified name prefixes to "trunc. log on checkpt."
CREATE PROCEDURE setSearchDBsToTruncLog AS DECLARE @dbid INT DECLARE @CMD VARCHAR(255) DECLARE @CMDstatus int SELECT @dbid = (SELECT MIN(dbid) FROM master..sysdatabases WHERE name LIKE "%SP" OR name LIKE "%RES") WHILE @dbid IS NOT NULL BEGIN SELECT @CMD = 'sp_dboption ' + DB_NAME(@dbid) + ',"trunc. log on chkpt.",true' EXEC (@CMD) SELECT @dbid = (SELECT MIN(dbid) FROM master..sysdatabases WHERE dbid > @dbid AND ( name LIKE "%SP" OR name LIKE "%RES")) END