20

when i analyzing running T-SQL I found a query that have {ts '2013-04-02 00:00:00'} in where clause. i was so curious about this and tried to find the source. It was executed by a CrystalReport Report.

here is the query.

SELECT *
FROM    [Table] B
WHERE   CONVERT(VARCHAR, [AddedDateTime], 111) 
        BETWEEN CONVERT(VARCHAR, {ts '2013-03-31 00:00:00'}, 111)
        AND     CONVERT(VARCHAR, {ts '2013-04-02 00:00:00'}, 111)

Can anyone tel me what is it and where we can use it?

SAM
  • 825
  • 1
  • 7
  • 15
  • i dont have any problem with it, i just wanted to know what is it and where we can use it – SAM Apr 02 '13 at 08:36

1 Answers1

31

It's an ODBC literal escape sequence

ODBC defines escape sequences for date, time, and timestamp literals. The syntax of these escape sequences is as follows:

{ts 'value'}

where we can use it?

Anywhere where a datetime value is expected. ("timestamp" is SQL Standard vernacular for what SQL Server calls datetime).

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
  • 4
    To complete the picture: JDBC uses the same escape sequences: http://docs.oracle.com/javase/6/docs/technotes/guides/jdbc/getstart/statement.html#1006519 –  Apr 02 '13 at 08:35