views:

281

answers:

3

I am creating a table that has a column called MonthName. When I defined this column the word "MonthName" showed up in blue like it was a reserved word. So I tried to look it up.

I cannot find it in Books Online or on Microsoft's site or even on our own SO.

I tried sp_help "monthname" and the reply was "The Object 'monthname' does not exists in database 'yourdb' or is invalid for this operation.

Here is the code

Create Table AtlasDataWarehouseReports.Calendar
(
    CalendarId    Integer NOT NULL,
    DateValue    Date NOT NULL,
    DayOfTheWeek   Integer NOT NULL,
    NameOfDay    VarChar (10) NOT NULL,
    MonthNumber    Integer NOT NULL,
    MonthName    VarChar (10) NOT NULL, 
    CalendarQuarter   Integer NOT NULL, 
    NameOfCalendarQuarter VarChar (20) NOT NULL,
    FinancialQuarter  Integer NOT NULL, 
    NameOfFinancialQuarter VarChar (20) NOT NULL, 
    CalendarYear   Integer NOT NULL,
    FinancialYear   Integer NOT NULL,
    WeekOfYear    Integer NOT NULL,
    JulianDay    Integer NOT NULL,
    USAIsBankHoliday  Bit  NOT NULL,
    USADayName    VarChar (100) NULL,
)
SQL Server Version Info
Microsoft SQL Server Management Studio  10.0.2531.0
Microsoft Analysis Services Client Tools 10.0.1600.22
Microsoft Data Access Components (MDAC) 3.85.1132
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0 
Microsoft Internet Explorer 8.0.6001.18702
Microsoft .NET Framework 2.0.50727.3082
Operating System 5.1.2600

What, pray, is MonthName in SQL 2008?

+1  A: 

as per msdn MonthName doesn't appear to be to be a reserved word.

mikeyickey
A: 

MONTHNAME is a reserved word in MySQL.

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_monthname

What IDE are you using that made the word show up as blue?

Kevin Crowell
It happens in SQL Server Management Studio (even 2005)
Sean Bright
question updated to show details.
Raj More
A: 

Have you or anyone in your team written a function MonthName already?

As per this, SQL 2005 has introduced MonthName function, it seems.

EDIT: I think this could have been added to support SQL Reporting Services.

EDIT2: I dont have SQL management studio but try typing in any of the Reporting Services function names to see if they are highlighted in blue.

shahkalpesh
You are incorrect. There is no MonthName function in SQL Server 2005.
Sean Bright
Its not me who is saying. Some guys on other forum discussing the same thing.
shahkalpesh
My apologies. That is what I assumed
shahkalpesh