Supplying a date when debugging a stored procedure

  • Hi there.

    I'm trying to debug a simple stored procedure in SQL Server 2000 using Query Analyzer. See code below ...

    CREATE  PROCEDURE TESTDATE (@MYDATE DATETIME) AS

    SELECT @MYDATE

    GO

    (my real stored procedure is much more complex ... I've just shown this simple one to better illustrate my issue).

    When I go into Query Analyzer to debug, I supply a date for @MYDATE and click the Execute button. It seems no matter what format I use for the date, I always get the following message ...

    [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

    This is driving me nuts! I'm I missing something obvious here? Help!

  • Hello again.

    I just realized that I posted this exact question several months ago and got the answer (which is to supply the date as 2004-12-31).

    I sorta remembered this but couldn't seem to find my question when I searched the forums.

    - Mike

  • Between your Windows Locale, Query Analyzer, and your connection settings, its easy for SQL Server to get the format wrong.

    For this reason I always recommend using dates in the format of 'dd Mon yyyy' ... as in 1 Jan 2005 or  23 Feb 1980 .... SQL Server has less trouble working out what part is the month, year, day.

    ... Unless of course your Locale or connection settings were set to a language other than english...


    Julian Kuiters
    juliankuiters.id.au

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply