July 10, 2012 at 12:46 pm
Urgent help needed, Thanks in advance.
Can I get T- SQL Script which displays for all the databases on the server.
DataName,
Physical_location,
DataSize,
DBGgrowth,
DB Max,
LogSize,
LogGrowth,
Log Max.
July 10, 2012 at 12:50 pm
Here's a starter for you
Select * from sys.master_files
From there, you can retrieve the information you need and customize the script to your needs.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 10, 2012 at 1:23 pm
Thanks SQLRNNR
But I was not able to get the right info Size, Can I have it in MB display.
Logical Name,
Physical_location,
DataSize,
DBGrowth,
DB Max,
LogSize,
LogGrowth,
Log Max.
July 10, 2012 at 1:30 pm
responses are being fragmented
Post further responses here
http://www.sqlservercentral.com/Forums/Topic1327652-391-1.aspx
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 10, 2012 at 1:37 pm
You should take a look at what the columns mean. http://msdn.microsoft.com/en-us/library/ms186782.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 10, 2012 at 2:49 pm
Everything except for the DB name can be found in sys.database_files. You can get db name with DB_NAME(). The procedure below will get you all this information for every DB on the SQL Instance you run it on.
Happy Databasing!
IF object_id('tempdb..#x') IS NOT NULL
DROP TABLE #x;
CREATE TABLE #x
(
[db]varchar(100),
[FileType]varchar(30),
[Physical_location]varchar(200),
[Size(mb)]int,
[MaxSize(mb)]bigint,
growthint,
is_percent_growthbit
);
EXEC sp_msforeachdb '
USE [?];
INSERT INTO #x
SELECTDB_NAME() [db],
type_desc [FileType],
physical_name [Physical_location],
size [Size(mb)],
max_size [MaxSize(mb)],
growth,
is_percent_growth
FROM sys.database_files
'
SELECT[db],
CASE (FileType)
WHEN 'ROWS' THEN 'Data file'
WHEN 'LOG' THEN 'Log File'
ELSE FileType
END [FileType],
[Physical_location],
([Size(mb)] * 8)/1024 [size(mb)],
([MaxSize(mb)] * 8)/1024 [MaxSize(mb)],
CASE
WHEN is_percent_growth = 0
THEN CAST(growth * 8/1024 AS varchar(10)) + 'MB'
ELSE
CAST(growth as varchar(10)) + '%'
END AS [File Growth]
FROM #x
ORDER BY [db], [FileType]
-- Itzik Ben-Gan 2001
July 10, 2012 at 2:52 pm
XMLSQLNinja (7/10/2012)
Everything except for the DB name can be found in sys.database_files. You can get db name with DB_NAME(). The procedure below will get you all this information for every DB on the SQL Instance you run it on.Happy Databasing!
IF object_id('tempdb..#x') IS NOT NULL
DROP TABLE #x;
CREATE TABLE #x
(
[db]varchar(100),
[FileType]varchar(30),
[Physical_location]varchar(200),
[Size(mb)]int,
[MaxSize(mb)]bigint,
growthint,
is_percent_growthbit
);
EXEC sp_msforeachdb '
USE [?];
INSERT INTO #x
SELECTDB_NAME() [db],
type_desc [FileType],
physical_name [Physical_location],
size [Size(mb)],
max_size [MaxSize(mb)],
growth,
is_percent_growth
FROM sys.database_files
'
SELECT[db],
CASE (FileType)
WHEN 'ROWS' THEN 'Data file'
WHEN 'LOG' THEN 'Log File'
ELSE FileType
END [FileType],
[Physical_location],
([Size(mb)] * 8)/1024 [size(mb)],
([MaxSize(mb)] * 8)/1024 [MaxSize(mb)],
CASE
WHEN is_percent_growth = 0
THEN CAST(growth * 8/1024 AS varchar(10)) + 'MB'
ELSE
CAST(growth as varchar(10)) + '%'
END AS [File Growth]
FROM #x
ORDER BY [db], [FileType]
You can simplify that by just using sys.master_files.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 10, 2012 at 3:03 pm
To get the number in MB:
value * 8 / 1024
Example:
Selectname,
size*8/1024
from sys.master_files
-- Itzik Ben-Gan 2001
July 10, 2012 at 3:19 pm
Thnaks XMLSQLNinja
Can we add 'Available Free Space of .mdf, .ndf, .ldf' to existing script
Your help is greatly appreciated!
July 10, 2012 at 3:25 pm
XMLSQLNinja (7/10/2012)
To get the number in MB:value * 8 / 1024
Example:
Selectname,
size*8/1024
from sys.master_files
Just divide by 128.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 10, 2012 at 3:29 pm
I need Available Free Space on of .mdf, .ndf, .ldf on whole instance addinf to existing script.
July 10, 2012 at 3:30 pm
Jeff Moden (7/10/2012)
XMLSQLNinja (7/10/2012)
To get the number in MB:value * 8 / 1024
Example:
Selectname,
size*8/1024
from sys.master_files
Just divide by 124.
Should be 128
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 10, 2012 at 3:31 pm
Danzz (7/10/2012)
I need Available Free Space on of .mdf, .ndf, .ldf on whole instance addinf to existing script.
You have been given enough info to find that info now. This is where you should make an effort at figuring that part out. You do that, then you will be on your way to becoming a better dba
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 10, 2012 at 3:35 pm
SQLRNNR (7/10/2012)
Jeff Moden (7/10/2012)
XMLSQLNinja (7/10/2012)
To get the number in MB:value * 8 / 1024
Example:
Selectname,
size*8/1024
from sys.master_files
Just divide by 124.
Should be 128
Wow... talk about phat phingering. Thanks for the catch and the correction.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 10, 2012 at 3:37 pm
I dont get any info from ' Select * from sys.master_files '.
Help please!
Viewing 15 posts - 1 through 15 (of 29 total)
You must be logged in to reply to this topic. Login to reply