ExamNotes.net  -  IT certification portal

ForumsCertResearchTop sitesNewslettersFree email
HomeRegister


Exams Notes
Practice exams
Exam games
Questions by email
Online training
Training videos
College degrees
Boot camps
Book store
Links directory
Tell a friend
For webmasters




General discussions > Public newsgroups > microsoft.public.sqlserver.server > List all Databases

Show a Printable Version
Email This Page to Someone!
Receive updates to this thread



Author List all Databases
Derrick King
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
List all Databases

I would like to produce a list of all Database/the Location of the
Database/Logfiles. I assume that there is a 'system' table that contains
this inof, but what is it

many thanks

Derrick


Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Mark Allison
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

EXEC sp_msforeachdb 'use ? exec sp_helpfile'

--
Mark Allison
http://www.allisonmitchell.com


"Derrick King" <derrick.king@bradford.gov.uk> wrote in message
news:amum0s$r46$1@newsreaderm1
.core.theplanet.net...
> I would like to produce a list of all Database/the Location of the
> Database/Logfiles. I assume that there is a 'system' table that contains
> this inof, but what is it
>
> many thanks
>
> Derrick
>
>



Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Anith Sen
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

Try:

SELECT *
FROM master..sysDatabases

--
- Anith




Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Luis F Rivera G
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

Better is:
EXEC sp_msforeachdb 'use ? exec sp_helpdb ?'
>-----Original Message-----
>EXEC sp_msforeachdb 'use ? exec sp_helpfile'
>
>--
>Mark Allison
>http://www.allisonmitchell.com
>
>
>"Derrick King" <derrick.king@bradford.gov.uk> wrote in

message
> news:amum0s$r46$1@newsreaderm1
.core.theplanet.net...
>> I would like to produce a list of all Database/the

Location of the
>> Database/Logfiles. I assume that there is a 'system'

table that contains
>> this inof, but what is it
>>
>> many thanks
>>
>> Derrick
>>
>>

>
>
>.
>

Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Anith Sen
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

sp_msforeachdb & sp_msforeachtable are undocumented they use
a cursor internally to loop through the databases/tables. Hence
there is no need to use a 'USE ?' in the arguments for these
procedures.

--
- Anith




Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Roy Harvey
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

Derrick,

>I would like to produce a list of all Database/the Location of the
>Database/Logfiles. I assume that there is a 'system' table that contains
>this inof, but what is it


Below is a system stored procedure you can add to the master database
that I think will give you what you want. Yes, it uses undocumented
features. For this type of tool I do not think it matters.

Roy


CREATE PROCEDURE sp__dba_useful_info
@DB varchar(15) = '%'
AS

CREATE TABLE #files
([DB Name] char(15),
[Db/Log] char(4),
MB decimal(15,2),
[Pages (8k)] int,
[File Name] varchar(25),
[File Location] varchar(50),
Maxsize char(18),
Growth char(18))

exec sp_msforeachdb "insert #files
SELECT 'DB Name' = '?',
'Db/Log' = (case status & 0x40 when 0x40 then 'Log' else 'Data'
end),
'MB' = convert(dec(15,2),convert(dec(
15,2),size * 8)/1024),
'Pages (8k)' = size,
'File Name' = substring(name,1,25),
'File Location' = substring(filename,1,50),
'Maxsize' = (case maxsize when -1 then N'Unlimited'
else
convert(nvarchar(15), maxsize * 8) + N' KB'
end),
'Growth' = (case status & 0x100000 when 0x100000 then
convert(nvarchar(3), growth) + N'%'
else
convert(nvarchar(15), growth * 8) + N' KB' end)
FROM ?..sysfiles
ORDER by fileid"

SELECT *
FROM #files
WHERE [DB Name] LIKE @DB

drop table #files



Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Mark Allison
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

Try it without the USE. It fails. Good point about it being undocumented. It
works though.

--
Mark Allison
http://www.allisonmitchell.com


"Anith Sen" <anith@bizdatasolutions.com> wrote in message
news:eoy3CUWZCHA.1728@tkmsftngp08...
> sp_msforeachdb & sp_msforeachtable are undocumented they use
> a cursor internally to loop through the databases/tables. Hence
> there is no need to use a 'USE ?' in the arguments for these
> procedures.
>
> --
> - Anith
>
>
>
>



Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Mark Allison
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

That doesn't show you the log files.

--
Mark Allison
http://www.allisonmitchell.com


"Anith Sen" <anith@bizdatasolutions.com> wrote in message
news:eo5YoLWZCHA.1668@tkmsftngp09...
> Try:
>
> SELECT *
> FROM master..sysDatabases
>
> --
> - Anith
>
>
>
>



Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
Anith Sen
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: List all Databases

You are absolutely right. I was referring about using it as
EXEC sp_msforeachdb 'EXEC ?..sp_helpfile' rather than switching
the context using USE.

Regarding getting the log file informations probably he could use

EXEC sp_msforeachdb '
SELECT *
FROM ?..sysfiles'

--
- Anith




Report this post to a moderator

Old Post 10-06-02 03:15 AM
Reply w/Quote Edit/Delete Message IP: Logged
All times are GMT.
Post new thread   Post reply


Forum Jump:
Rate This Thread:
Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is OFF.
 

ExamNotes forum archive


Powered by: vBulletin 2.2.8
Copyright ©2000, Jelsoft Enterprises Limited.

  Free Braindumps | mcse braindumps