Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shrink logs
Message
 
To
10/07/2009 17:04:56
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01411487
Message ID:
01411533
Views:
30
>It is in the system views for each DB. look for sys.sysaltfiles
sp_MSForEachDb 'IF LOWER(''?'') NOT IN (''master'', ''tempdb'', ''tempdev'', ''model'', ''msdb'')
                 BEGIN
                     declare @LogFile nvarchar(2000)
                     declare @ExeString nvarchar(2000)
                     USE [?]
                     SELECT @LogFile = sys.sysaltfiles.name
                            FROM sys.sysdatabases
                     INNER JOIN sys.sysaltfiles ON sys.sysdatabases.dbid = sys.sysaltfiles.dbid
                     WHERE (sys.sysaltfiles.fileid = 1) AND (sys.sysdatabases.name = ''?'')
                     print @LogFile
                     ALTER DATABASE [?] SET RECOVERY SIMPLE
                     DBCC SHRINKFILE (@LogFile, 1)
                     ALTER DATABASE [?] SET RECOVERY FULL
                 END'
But kill me for TempDB :-)))
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform