-- Cursors are bad kids! Don't use them ... DECLARE @DatabaseName VARCHAR(200) DECLARE DatabaseCursor CURSOR FOR SELECT name FROM sys.databases where database_id > 4 OPEN DatabaseCursor FETCH NEXT FROM DatabaseCursor INTO @DatabaseName WHILE @@FETCH_STATUS = 0 BEGIN PRINT @DatabaseName -- Do other stuff to databases here, -- e.g DBCC CHECKDB(@Variable) FETCH NEXT FROM DatabaseCursor INTO @DatabaseName END CLOSE DatabaseCursor DEALLOCATE DatabaseCursor
No comments:
Post a Comment