Access数据库转SQL后Instr的问题
在Access数据库中可正常运行的语句:
"select count(*) from TD_TZ where Instr(','&ReadUsr&',',',"&Request.Cookies("usr")&",')=0 And Myname<>'"&Request.Cookies("usr")&"'"
怎样改为SQL能正常运行的语句?因为SQL没有Instr这个函数,charindex有各instr相似的作用,我改成这样:
"select count(*) from TD_TZ where charindex(',"&Request.Cookies("usr")&",',(',' & ReadUsr & ','))=0 And Myname<>'"&Request.Cookies("usr")&"'"
不能正常运行,可能是(',' & ReadUsr & ',')错了,望高手指点,谢谢!
答案:SQL SERVER 是用 + 号作连字符的!
"select count(*) from TD_TZ where charindex('," & Request.Cookies("usr") & ",' , ',' + ReadUsr + ',' )=0 And Myname<>'" & Request.Cookies("usr") & "'"
其他:"select count(*) from TD_TZ where charindex(',"&Request.Cookies("usr")&",',(',' & ReadUsr & ','))=0 And Myname<>'"&Request.Cookies("usr")&"'"
打印成string贴出来看看
上一个:access 数据库正则替换的问题
下一个:ACCESS通过ODBC连接oracle数据库(oracle里表的字段超过256列)