Sunday, February 19, 2012

How to know allocation place for each object?

Hi all of you,

My current dutie is try to obtain for each table their filegroup.

I'm seeing sysobjects table but I can't see nothing related to do with

Thanks a lot for your time,

Ok, if you run this query you obtain such name but it is not enought for my goal:

sp_help <table>

|||

Not sure if this is something you're after, this will list each object with their associated filegroup, you can filter sysobjects for tables only, not pretty unfortunately but works:

SET NOCOUNT ON

DECLARE @.sqltxt varchar(4000);

DECLARE @.tblName varchar(4000);

DECLARE GetFG_Cursor CURSOR FOR

Select 'sp_objectfilegroup ' + CAST(id AS VARCHAR(4000)), name from sysobjects;

OPEN GetFG_Cursor;

FETCH NEXT FROM GetFG_Cursor INTO @.sqltxt,@.tblName;

WHILE @.@.FETCH_STATUS = 0

BEGIN

PRINT 'Table Name: ' + @.tblName;

EXECUTE(@.sqltxt);

FETCH NEXT FROM GetFG_Cursor INTO @.sqltxt,@.tblName;

END

CLOSE GetFG_Cursor;

DEALLOCATE GetFG_Cursor;

|||

hi xrayb,

That's a good approximation. Thanks indeed.

It'll be helpful.

No comments:

Post a Comment