locked
read only mode RRS feed

  • Question

  • hi is there a query that returns me the read-only status of a TABLE?!?!? the thing is that looks like only one table is on read only mode in my database
    Wednesday, August 5, 2009 8:20 PM

Answers

  • tables cant be read only; however, file groups can be read only.  You can use the query below to check the file group settings of the table.

    SELECT
        t.NAME AS Table_Name,
        f.NAME AS FG_Name,
        is_default,
        is_read_only
    FROM
        sys.indexes i
    INNER JOIN sys.filegroups f
        ON i.data_space_id = f.data_space_id
    INNER JOIN sys.tables t
        ON i.OBJECT_ID = t.OBJECT_ID
    WHERE
        t.TYPE = 'U'
        AND t.is_ms_shipped = 0
        AND i.type IN (0,1) --0=heap,1=clustered index
        AND t.NAME = 'MyTableName'

    http://jahaines.blogspot.com/
    • Edited by Adam Haines Wednesday, August 5, 2009 8:39 PM syntax
    • Proposed as answer by Azher Aziz Thursday, August 6, 2009 6:08 AM
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 7:56 AM
    Wednesday, August 5, 2009 8:38 PM

All replies

  • tables cant be read only; however, file groups can be read only.  You can use the query below to check the file group settings of the table.

    SELECT
        t.NAME AS Table_Name,
        f.NAME AS FG_Name,
        is_default,
        is_read_only
    FROM
        sys.indexes i
    INNER JOIN sys.filegroups f
        ON i.data_space_id = f.data_space_id
    INNER JOIN sys.tables t
        ON i.OBJECT_ID = t.OBJECT_ID
    WHERE
        t.TYPE = 'U'
        AND t.is_ms_shipped = 0
        AND i.type IN (0,1) --0=heap,1=clustered index
        AND t.NAME = 'MyTableName'

    http://jahaines.blogspot.com/
    • Edited by Adam Haines Wednesday, August 5, 2009 8:39 PM syntax
    • Proposed as answer by Azher Aziz Thursday, August 6, 2009 6:08 AM
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 7:56 AM
    Wednesday, August 5, 2009 8:38 PM
  • Msg 208, Level 16, State 1, Line 1
    Invalid object name 'sys.indexes'.
    Msg 208, Level 16, State 1, Line 1
    Invalid object name 'sys.filegroups'.
    Msg 208, Level 16, State 1, Line 1
    Invalid object name 'sys.tables'.
    Wednesday, August 5, 2009 8:53 PM
  • What version of SQL are you using?
    http://jahaines.blogspot.com/
    Wednesday, August 5, 2009 9:50 PM
  • You have to execute the above mentioned query in master
    Thursday, August 6, 2009 6:09 AM