Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shrink logs
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01411487
Message ID:
01411528
Views:
46
>>>>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'
>
Yes, very strange - why does it still try to change tempdb?
Msg 5058, Level 16, State 1, Line 11
Option 'RECOVERY' cannot be set in database 'tempdb'.
ReportServer$IOTECHSQL2008
ReportServer$IOTECHSQL2008
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
ReportServer$IOTECHSQL2008TempDB
ReportServer$IOTECHSQL2008TempDB
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Test
Test
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

(8 row(s) affected)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform