Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 need query

Author  Topic 

sql2020
Yak Posting Veteran

54 Posts

Posted - 2011-05-26 : 00:07:42
Hi ALL,

Need query to fetch these below records:

Instance name,

Database name,

App Name,

DB Owner,

Status,

DB SIZE,

Region,

Time,

Type,

MDF file location,

LDF file LOCation,

Logshipping to server,

Logshipping to database


Regards

sql2020

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-26 : 00:51:33
use SERVERPROPERTY and DATABASEPROPERTY properties to get some info. You need to write scripts for other info such as DB size etc.. search online .. theres tons of scripts all over...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sql2020
Yak Posting Veteran

54 Posts

Posted - 2011-05-26 : 23:30:16
HI ,

For dbname, DB size, i am using sp_spaceused

for MDF,LDF location i am using " Select * from sysfiles

that to each database i need to run these queries

i have around 40 servers each servers have 20 databases. is there any way to get those data with single query.

please help on this

sql2020
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-05-27 : 10:19:08
You can use an undocumented procedure named sp_MSforeachdb to run a script against every database on one server/instance. Running a script against a set of servers is more problematic. We do that at the application level. We have an application that has knowledge of a set of servers and their databases. From the application, we run scripts against all databases to gather file statistics but can run other scripts against specific subsets of databases (e.g., Add this User to all Accounting databases).

=======================================
Elitism is the slur directed at merit by mediocrity. -Sydney J. Harris, journalist (1917-1986)
Go to Top of Page
   

- Advertisement -