|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Yesterday @ 10:04 AM
Points: 753,
Visits: 3,786
|
|
Our abbreviations are beginning to overlap often. Since I like audo, I see "DAC" and I think "Digital to Analogue Converter."
______________________________________________________________________ The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, February 02, 2009 10:07 AM
Points: 81,
Visits: 23
|
|
| Thanks for the updated code. this code will be a great asset for all dba's.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, February 09, 2012 4:42 AM
Points: 29,
Visits: 396
|
|
We learn every day, but my SSMS complains about the line: "CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st". I do not know what is going wrong. Leendert.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, June 14, 2013 6:35 AM
Points: 306,
Visits: 1,020
|
|
Are you executing the code on a SQL 2005? Does not work on SQL 2000.
Here is the link for more information on CROSS APPLY
http://msdn.microsoft.com/en-us/library/ms177634.aspx
Rudy
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, February 09, 2012 4:42 AM
Points: 29,
Visits: 396
|
|
Rudy, thanks.
I am using SQL Server 2005, Leendert.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, January 19, 2011 2:42 PM
Points: 8,
Visits: 39
|
|
Need some help...
The following gives an error.
SELECT '--Shows avail free DB space ' as ' ' exec sp_MSForEachDB 'Use ? SELECT name AS ''Name of File'', size/128.0 -CAST(FILEPROPERTY(name, ''SpaceUsed'' ) AS int)/128.0 AS ''Available Space In MB'' FROM .SYSFILES'
I also got this when I tried to execute - EXEC sp_msForEachDB 'PRINT ''?'''
Could not find stored procedure 'sp_msForEachDB'.
We are on SQL Server Enterprise 2005
Any ideas ?
Regards
Gagan
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Wednesday, June 05, 2013 1:56 PM
Points: 769,
Visits: 1,167
|
|
It worked fine for me on SQL 2008
You have to remove the period and lower case 'sysfiles' (SYSFILES won't work for me)
exec sp_MSForEachDB 'Use ? SELECT name AS ''Name of File'', size/128.0 -CAST(FILEPROPERTY(name, ''SpaceUsed'' ) AS int)/128.0 AS ''Available Space In MB'' FROM sysfiles' --select * from sysfiles
SQLServerNewbie
MCITP: Database Administrator SQL Server 2005
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 7:03 PM
Points: 1,696,
Visits: 1,746
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, January 19, 2011 2:42 PM
Points: 8,
Visits: 39
|
|
I tried this
SELECT '--Shows avail free DB space ' as ' ' exec sp_MSForEachDB 'Use ? SELECT name AS ''Name of File'', size/128.0 -CAST(FILEPROPERTY(name, ''SpaceUsed'' ) AS int)/128.0 AS ''Available Space In MB'' FROM sysfiles'
Gave me the following output
(1 row(s) affected) Msg 2812, Level 16, State 62, Line 2 Could not find stored procedure 'sp_MSForEachDB'.
Results was only --Shows avail free DB space
Is the installation missing the procedure ?
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, February 03, 2012 6:55 AM
Points: 432,
Visits: 75
|
|
That was definitley a nice article and the code works. I only had to do minor changes like:
exec sp_MSForEachDB 'Use [?] SELECT name AS ''Name of File'', size/128.0 -CAST(FILEPROPERTY(name, ''SpaceUsed'' ) AS float)/128.0 AS ''Available Space In MB'' FROM sysfiles'
They way you had it wriiten does not support case sensitive collation.
|
|
|
|