TSQL Execution inconsistency

  • Can anyone tell me why SQL Server Agent, when executing "SELECT [DATE], [TIME]", gives me as output one record, two INT columns containing the current date and the current time?

    I.e executed today gives:

    ----------- -----------

    20050223    115419

    But "SELECT [Date], [Time]" fails with: Invalid column name 'Date'. [SQLSTATE 42S22] (Error 207)  Invalid column name 'Time'.

    also "SELECT Date, Time" and "SELECT DATE, TIME" fails.

    Any ideas?

  • The SQL Server Agent has available certain case-sensitive tokens which are replaced at run time with the actual values.  These are primary used for Alert Response job steps.  There are 15 tokens that include [DATE] and [TIME].

    See sp_add_jobstep in Book OnLine for all of the tokens. 

    SQL = Scarcely Qualifies as a Language

  • Oh, I didn't know this feature!

    Thanx,

    Hanslindgren

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

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