jeudi 1 mars 2012

Requête utile ...

Bonjour,

   J'ai souvent cette demande : Les participants souhaitent connaitre dans quel groupe de fichiers appartiennent les objets.

Voici un exemple de scprit
****************************************
SELECT s.name AS SCHEMA_NAME, o.name AS OBJECT_NAME, o.type_desc AS OBJECT_TYPE,ds.name AS STORAGE, dbf.physical_name AS FILENAME, ds.type_desc AS STORAGE_TYPE,i.name AS index_name, i.index_id, i.type_desc AS index_type,
p.partition_id, p.partition_number AS pnum, p.rows AS partition_rows,a.allocation_unit_id AS alloc_unit_id, a.type_desc AS page_type_desc, a.total_pages AS pages,internals.total_pages, internals.used_pages, internals.data_pages,
first_page, root_page, first_iam_pageFROM sys.objects AS oINNER JOIN sys.schemas AS sON o.schema_id = s.schema_idINNER JOIN sys.indexes AS iON o.object_id = i.object_idINNER JOIN sys.partitions pON p.object_id = i.object_idAND p.index_id = i.index_idINNER JOIN sys.allocation_units aON a.container_id = p.partition_idINNER JOIN sys.data_spaces dsON ds.data_space_id = a.data_space_idLEFT OUTER JOIN sys.database_files dbfON dbf.data_space_id = ds.data_space_idINNER JOIN sys.system_internals_allocation_units internals
ON internals.container_id = a.container_id
Where o.type_desc= 'USER_TABLE'
****************************************

Bonne Lecture
Thierry

Aucun commentaire:

Enregistrer un commentaire