首页 文章

转换DateTime时无法查询SQL给出语法错误

提问于
浏览
0

从SQL Server Management Studio进行此SQL查询时出现语法错误:

exec QData N'Name,Value,TimeStamp', 
     convert(datetime, '2013-11-25 03:25:02.000'), 
     N'IncludeBounding', N'Root.BDV101.Response.Value'

它说

关键字'convert'附近的语法不正确

谁知道为什么?

编辑:

如果我执行以下操作,它可以工作(没有错误)

Declare @time datetime
Set @time = '2013-11-25 03:25:02.000'
exec QData N'Name, Value, TimeStamp', @time, N'IncludeBounding', N'Root.BDV101.Response.Value'

2 回答

  • 0

    您可以使用隐式转换,如下所示:

    exec QData N'Name,Value,TimeStamp','20131125 03:25:02.000',N'IncludeBounding',N'Root.BDV101.Response.Value'
    
  • 0

    请尝试此操作,不进行转换,默认情况下将采用Datatime DAtatype

    exec QData N'Name,Value,TimeStamp','2013-11-25 03:25:02.000' ,N'IncludeBounding',N'Root.BDV101.Response.Value'
    

相关问题