Giter VIP home page Giter VIP logo

[Request] sp_spaceused <table> output with sp_helpme would be useful about dba-multitool HOT 2 CLOSED

lowlydba avatar lowlydba commented on June 10, 2024
[Request] sp_spaceused output with sp_helpme would be useful

from dba-multitool.

Comments (2)

felipeschneider88 avatar felipeschneider88 commented on June 10, 2024

Hello, Glenn Barry in his Feb'21 release of magic DMV's add this code

-- Get Table names, row counts, and compression status for clustered index or heap (Query 40) (Table Sizes) SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], SUM(p.Rows) AS [RowCount], data_compression_desc AS [CompressionType] FROM sys.partitions AS p WITH (NOLOCK) INNER JOIN sys.objects AS o WITH (NOLOCK) ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE);

We can change that to add a where clause with the table like this
OBJECT_NAME(p.object_id) = @TableName

Here it's the link to the Glenn's site: https://glennsqlperformance.com/

from dba-multitool.

lowlydba avatar lowlydba commented on June 10, 2024

Thanks for the suggestion folks.

I'm not sure I see the value in either directly or indirectly combining sp_spaceused information into sp_helpme, when one can just run the stored procedures back to back to fetch the info. You can always write your own wrapper to call them both if the input is a table, too.

This stored procedure is intended to be an enhanced version of sp_help, not a kitchen sink. If there are parts of sp_spaceused that are lacking, creating a new version might be a worthwhile effort, though I haven't found myself wishing it behaved differently to be honest.

from dba-multitool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.