• I don't understand why the use of a case when a simple function would do the job. . .

    My original suggestion fulfills the requirements: -

    DECLARE @getmonth TINYINT,

    @datestring VARCHAR(20),

    @input VARCHAR(20)

    SET @input = 'January'

    SET @datestring = @input + ' 1 2010'

    SET @getmonth = MONTH(CAST(@datestring AS DATETIME))

    SELECT @getmonth

    As does the post below mine which basically shortened the code.

    DECLARE @month AS VARCHAR(20)

    SET @Month = 'January'

    SELECT MONTH(@month + ' 1 2010')

    They'd both also work if you used short names for the months, e.g. "Jan", "Feb" etc. Making them more efficient than a Case, since you'd need to have 24 arguments to replicate it.

    Unless I'm missing something?


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/