Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shrink logs
Message
From
11/07/2009 02:41:47
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01411487
Message ID:
01411568
Views:
40
>>It is in the system views for each DB. look for sys.sysaltfiles
>>
>>>>Thank you all for your efforts. I did try this also, and while the IF condition is important, it is not critical. The bigger trouble is that it does not find the correct sysaltfiles and I get several errors:
>>>>
>>>>Invalid object name 'dbo.sysaltfiles'.
>>>>
>>>Yes, I got the same errors too. BTW, where is sysAltFiles? I was trying to see it, but I can not.
>
>This is George Mastros solution
>
>
>sp_msforeachdb 'If ''?'' Not In (''master'',''tempdb'',''model'',''msdb'') 
>      Begin
>            Declare @LogFile nvarchar(2000)
>            Select @LogFile = Name From master..sysaltfiles Where db_name(dbid) = ''?'' And Fileid = 2
>            Set @LogFile = ''Create Procedure dbo.ShrinkMe As 
>                  ALTER DATABASE [?] SET RECOVERY SIMPLE
>                  dbcc ShrinkFile('' + @LogFile + '')
>                  ALTER DATABASE [?] SET RECOVERY FULL''
> 
>            use [?]
>            If Exists(Select * From [?].Information_Schema.Routines Where Specific_Name = ''ShrinkMe'')
>                  Begin
>                        drop Procedure ShrinkMe
>                  End
>            use [?]     
>            Exec (@LogFile)   
>            --print(@LogFile)
>            exec [?].dbo.ShrinkMe
>      End '
>
>
>Works great on my computer too.


Did George explain WHY tempdb is not skipped?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform