Advertisement

11.10.2005 at 01:07AM PST, ID: 21626020
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.6

SQL Report error

Asked by TRAININGBSC in MS SQL Server

Tags: , , ,

Hi,

I'm trying to run the following TSQL statement on a Windows SQL 2000 platform;

/* Space used per DB */

USE master
GO
SET NOCOUNT ON
GO
DECLARE AllDatabases CURSOR FOR
SELECT name FROM sysdatabases -- WHERE dbid > 4

OPEN AllDatabases
DECLARE @DBNameVar NVARCHAR(128)
DECLARE @Statement NVARCHAR(500)

 
PRINT ''
PRINT ''
PRINT 'Server Name: ' + @@SERVERNAME
PRINT ''

PRINT 'Report Generated on:  ' + cast(getdate() as char(20))
PRINT ''

PRINT 'Report Name: Space used per database'
PRINT ''


declare @user CHAR(40)
set @user = suser_sname()
PRINT 'Report Executed by: ' + @user
PRINT ''

FETCH NEXT FROM AllDatabases INTO @DBNameVar
WHILE (@@FETCH_STATUS = 0)
BEGIN
    PRINT N'CHECKING DATABASE ' + @DBNameVar


    SET @Statement = N'USE [' + @DBNameVar + ']' + CHAR(13)
      
        + N'declare @dbsize dec(15,0)' + char(13)
      + N'declare @bytesperpage      dec(15,0)' + char(13)
      + N'declare @pagesperMB            dec(15,0)' + char(13)

      + N'select @dbsize = sum(convert(dec(15),size))
            from dbo.sysfiles' + char(13)

      + N'select @bytesperpage = low
            from master.dbo.spt_values
            where number = 1
                  and type = "E"' + char(13)

      + N'select @pagesperMB = 1048576 /@bytesperpage' + char(13)

      + N'select  database_name = substring(db_name(),1,30),
            database_size =
                  ltrim(str(@dbsize/@pagesperMB,15,2) + " MB")'

    EXEC sp_executesql @Statement
    PRINT CHAR(13) + CHAR(13)
     
    FETCH NEXT FROM AllDatabases INTO @DBNameVar
END

CLOSE AllDatabases
DEALLOCATE AllDatabases
GO
SET NOCOUNT OFF
GO

PRINT ''
PRINT ''
PRINT 'END OF REPORT'
PRINT ''

It returns the following error:

CHECKING DATABASE BELd
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE Bel
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE BS
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE ca
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE CAO
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE CSS_W
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE CSS
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE CT
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 3, Line 5
Invalid column name ' MB'.



CHECKING DATABASE CW
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE D
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE FRA
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE Jon's DB
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE LON
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE master
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE model
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE mon
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE msdb
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE Northwind
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE pubs
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE rec
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE S
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE tempdb
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE T
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE V
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE wf
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.



CHECKING DATABASE Y
Server: Msg 207, Level 16, State 3, Line 2
Invalid column name 'E'.
Server: Msg 207, Level 16, State 1, Line 5
Invalid column name ' MB'.

I'm sure I'm overlooking something really simple. Can anyone help?

thanksStart Free Trial
[+][-]11.10.2005 at 01:14AM PST, ID: 15263685

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.10.2005 at 01:18AM PST, ID: 15263706

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.10.2005 at 01:28AM PST, ID: 15263743

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: msg, level, state, sql
Sign Up Now!
Solution Provided By: Lowfatspread
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-43