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:
01411525
Vues:
44
>>>Hi Boris,
>>>
>>>Looks like IF ? in condition is ignored.
>>>
>>Maybe you have Case sensitive server?
>
>No, I don't think so. Did you try running your script? I got
>
>Msg 5058, Level 16, State 1, Line 10
>Option 'RECOVERY' cannot be set in database 'tempdb'.
>Msg 208, Level 16, State 1, Line 6
>Invalid object name 'dbo.sysaltfiles'.

That worked for all DBs except tempdb and kill me I don't know why. It didn't go INTO the if, because there is NO print of the DBName:
sp_MSForEachDb 'IF LOWER(''?'') NOT IN (''master'', ''tempdb'', ''model'', ''msdb'')
                   BEGIN
                     print ''?'' -- HERE - No TEMPDB in the Message tab
                     declare @LogFile nvarchar(2000)
                     print ''?''
                     USE [?]
                     SELECT @LogFile = master.dbo.sysaltfiles.name
                            FROM master.dbo.sysdatabases
                     INNER JOIN master.dbo.sysaltfiles ON master.dbo.sysdatabases.dbid = master.dbo.sysaltfiles.dbid
                     WHERE (master.dbo.sysaltfiles.fileid = 1) AND (master.dbo.sysdatabases.name = ''?'')
                     ALTER DATABASE [?] SET RECOVERY SIMPLE
                     DBCC SHRINKFILE (@LogFile, 1)
                     ALTER DATABASE [?] SET RECOVERY FULL
                 END'
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