Cool Maintenance T-SQL Scripts

How to run an integrity check on all databases DECLARE @SQL VARCHAR(1000) DECLARE @DB sysname DECLARE curDB CURSOR FORWARD_ONLY STATIC FOR SELECT [name] FROM master..sysdatabases WHERE [name] NOT IN ('tempdb') and DATABASEPROPERTYEX(name, 'Status') != 'OFFLINE' ORDER BY [name] OPEN curDB FETCH NEXT FROM curDB INTO @DB WHILE @@FETCH_STATUS = 0 BEGIN SELECT @SQL = 'USE... Continue Reading →

Create a website or blog at

Up ↑