Welcome Guest, you are in: Anmelden

CP Wiki

RSS RSS

Navigation



  1. Administration

Suche im wiki
»
 » Startseite » netFrame als Plattform Menü » Tipps und Tricks » Cursor Alternative | » Erweiterte Suche

DECLARE @query VARCHAR(100), @dbname sysname

DECLARE BadCursor CURSOR FOR SELECT name FROM sys.databases WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb')

OPEN BadCursor FETCH NEXT FROM BadCursor INTO @dbname WHILE @@FETCH_STATUS = 0 BEGIN SELECT @query = 'dbcc checkdb(' + quotename(@dbname) + ')' EXEC (@query) FETCH NEXT FROM BadCursor INTO @dbname END CLOSE BadCursor DEALLOCATE BadCursor GO


Noch ein kleines Beispiel für das Erstellen einer Tabelle.

DECLARE @query VARCHAR(100), @dbname sysname DECLARE @dblist TABLE(dbname sysname)

INSERT INTO @dblist(dbname) SELECT name FROM sys.databases WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb')

WHILE (SELECT count(*) FROM @dblist) > 0 BEGIN SELECT top 1 @dbname = dbname FROM @dblist SELECT @query = 'dbcc checkdb(' + quotename(@dbname) + ')' EXEC(@query) DELETE FROM @dblist WHERE dbname = @dbname END GO

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam.