August 18, 2008 at 8:05 am
When I run the following command:
EXEC sp_msforeachdb @COMMAND1="select '?', filename, size from sysfiles"
It returns each database name, but it only returns the filenames from the databse I'm currently in:
master D:\SQLServer\Data\JoeTest.mdf 12800
master E:\SQLServer\Logfiles\JoeTest_log.ldf 6400
tempdb D:\SQLServer\Data\JoeTest.mdf 12800
tempdb E:\SQLServer\Logfiles\JoeTest_log.ldf 6400
My understanding was, this SP was to run the command against EACH database returned by the sp_msforeachdb. Am I thinking about this wrong?
August 18, 2008 at 8:28 am
What it really does it iterate over the list of databases and replaces the "?" with the database name, so for your query you would want to do this:
EXEC sp_msforeachdb @COMMAND1='select ''?'', filename, size from ?..sysfiles'
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 18, 2008 at 8:31 am
Thanks! I tried "close to that" before, but I had the ? in quotes for some reason.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply