List all tables and filenames for each

  • Is there a single command that I could execute in T-SQL that would list all tables and the file they "lived" in for a given database?  If not, what would you recommend to produce such an output?

    Thanks for the help...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Is this what you're looking for ?

    this query uses native sqlserver systemtables . 

    SELECT  FG.groupid AS GroupID

    , SUBSTRING(FG.groupname,1,30) AS FilegroupName

    , SUBSTRING(O.name,1,30) AS ObjectName

    , ix.indid, ix.name as indexname

    , F.filename as FileNames

    FROM sysobjects O

     INNER JOIN sysindexes IX

      ON O.id = IX.id

     INNER JOIN sysfilegroups FG

      ON IX.groupid = FG.groupid

     INNER JOIN sysfiles F

      on F.groupid = FG.groupid

    WHERE   O.xtype = 'U'

    ORDER BY  FG.groupname, O.ObjectName

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Very nice alzdba!  It's exactly what I needed.  Thanks for coming through on such short notice... I was really in a crunch and you've just made it possible for me to complete under the wire.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Keep in mind filegroup-files are balanced within a group, so your maxcapacity is the size of the smallest file * the number of files in the filegroup.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply