Home Forums SQL Server 2008 SQL Server 2008 - General Determine if a database is read-only when the log is not marked as read-only so DBCC SHRINKFILE may be skipped? RE: Determine if a database is read-only when the log is not marked as read-only so DBCC SHRINKFILE may be skipped?

  • John,

    I need the File_ID to pass to DBCC SHRINKFILE - but I'm all ears in terms of suggestions.

    SELECT @Log = FILE_ID,

    @DB = Name

    FROM sys.database_files

    WHERE type_desc = ''Log'';

    DBCC SHRINKFILE( @Log, TRUNCATEONLY );

    Thanks,

    Doug