Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shrink logs
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01411487
Message ID:
01411568
Vues:
39
>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform