>>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)
>
> 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.