home links tools blog about
home

« Taming Feature-Creep with VS.NET | Main | IIS ADMIN MMC 6.0 Fails the Usability Test »

November 13, 2003

Comments

pm

could that be modified to show table owner info as well? thanks, pm

Michael K. Campbell

Sure. The key to doing that is just to grab the userid from the name of the table. There's a killer SQL Server function: OBJECTPROPERTY that will do it for you. Once that's done, just join against that value to a suitable table (sysusers) and you're good to go. Replace the SELECT * FROM ... (down near the bottom) with this: SELECT u.[name] [owner],* FROM #sizes s INNER JOIN dbo.sysusers u ON u.uid = OBJECTPROPERTY(OBJECT_ID(s.[name]),'OwnerId') ORDER BY CAST(REPLACE(s.data,' KB','') AS int) DESC

pm

thanks! much appreciated...

Michael K. Campbell

A cleaner version of this would be to run the foreachtable sproc call with the following command:

EXECUTE sp_MSforeachtable
@command1 = 'INSERT INTO #sizes EXEC sp_spaceused ''?'''

(which is more stable and easier to read)

SQL Server Hosting

Thanks Michael for writing and posting your code. What a timesaver for those of us using shared hosting!

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)