Msg 156,级别15,状态1,第2行关键字'convert'附近的语法不正确。 [英] Msg 156, level 15, state 1, line 2 incorrect syntax near the keyword 'convert'.

查看:786
本文介绍了Msg 156,级别15,状态1,第2行关键字'convert'附近的语法不正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我这个,我是sql的新手无法找到错误。



CREATE INDEX CustomerHistory_SMS

ON CustomerHistory(customerid,convert(varchar,transactiondts,112))



我尝试过:



CREATE INDEX CustomerHistory_SMS

ON CustomerHistory(customerid,convert(varchar,transactiondts,112))

解决方案

< blockquote> https://www.sqlshack.com/how-to -create-index-on-sql-server-calculated-columns / [ ^ ]


您打算将索引放在什么位置?



我会说SQL Server告诉你不能在CREATE INDEX语句中使用CONVERT函数。我真的不知道你为什么要这样。



这是我要尝试的事情

  CREATE   INDEX  CustomerHistory_SMS 
ON CustomerHistory(customerid,transactiondts)


Hi, Can any one help me on this, I'm New in sql unable to find the error.

CREATE INDEX CustomerHistory_SMS
ON CustomerHistory (customerid,convert(varchar,transactiondts,112))

What I have tried:

CREATE INDEX CustomerHistory_SMS
ON CustomerHistory (customerid,convert(varchar,transactiondts,112))

解决方案

https://www.sqlshack.com/how-to-create-indexes-on-sql-server-computed-columns/[^]


What are you trying to place an Index on?

I would say that SQL Server is telling you that you can't use the CONVERT function inside of the CREATE INDEX statement. I really don't know why you would want to.

Here is what I would try

CREATE INDEX CustomerHistory_SMS
ON CustomerHistory (customerid, transactiondts)


这篇关于Msg 156,级别15,状态1,第2行关键字'convert'附近的语法不正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆