SQL 什么是 {ts '2013-04-02 00:00:00'}?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15759458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:36:00  来源:igfitidea点击:

What is {ts '2013-04-02 00:00:00'}?

sqlsql-servercrystal-reports-2008

提问by SAM

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.

当我分析正在运行的 T-SQL 时,我发现一个查询在 where 子句中有{ts'2013-04-02 00:00:00'} 。我对此很好奇,并试图找到来源。它由 CrystalReport 报告执行。

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?

谁能告诉我它是什么以及我们可以在哪里使用它?

回答by Damien_The_Unbeliever

It's an ODBC literalescape sequence

这是一个ODBC 文字转义序列

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

ODBC 为日期、时间和时间戳文字定义转义序列。这些转义序列的语法如下:

{ts 'value'}


where we can use it?

我们可以在哪里使用它?

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

任何需要datetime值的地方。(“时间戳”是 SQL Server 所称的 SQL 标准白话datetime)。