gpt4 book ai didi

TSQL -- 将日期插入动态 SQL

转载 作者:行者123 更新时间:2023-12-04 10:02:36 25 4
gpt4 key购买 nike

考虑以下 TSQL:

SET @WhereClause1 = 'where a.Date > ' + @InvoiceDate

我收到日期/字符串转换错误。 @InvoiceDate是一个日期时间变量。什么是正确的语法?

最佳答案

这可能会奏效。

SET @WhereClause1 = 'where a.Date > ''' + convert(varchar, @InvoiceDate) + ''''

尽管如果值为 null 会引发错误。

关于TSQL -- 将日期插入动态 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/708361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com