Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

sp_MSForeachdb then sp_MSforeachtable Expand / Collapse
Author
Message
Posted Friday, July 19, 2013 6:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 23, 2013 4:31 AM
Points: 1, Visits: 57
To get dB size with Path for each dBs on server.

SELECT d.name,
ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs,
PHYSICAL_NAME
FROM master.sys.master_files mf
INNER JOIN master.sys.databases d ON d.database_id = mf.database_id
WHERE mf.database_id > 4 -- Skip system databases
GROUP BY d.name, PHYSICAL_NAME
ORDER BY d.name
Post #1475409
Posted Wednesday, October 29, 2014 1:16 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 9, 2014 1:10 PM
Points: 1, Visits: 30
YOU CAN TRY WITH THIS

CREATE PROCEDURE usp_DataRowCounts AS

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
EXEC sp_MSForeachdb @replacechar='%', @command1= " USE %
IF DB_ID('%')>4 begin
INSERT TEST_table
EXEC sp_msforeachtable 'sp_spaceused ''?'''
end"
Post #1629636
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse