在从字符串到int的转换中使用escape [英] using escape in covertion from string to int
本文介绍了在从字符串到int的转换中使用escape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想将字符串转换为int但是'/''应该被转义。
我正在尝试:
Hi I want to convert string to int but ''/'' should be escaped.
I''m trying :
select [R-Date] from Reg where (CONVERT(INT,Reg.[R-Date] ESCAPE'/') BETWEEN 13920201 AND 13920222
我收到错误:
but I get error :
Incorrect syntax near the keyword 'ESCAPE'.
当我删除逃脱时''/''我得到:
and when I remove escape ''/'' I get:
Conversion failed when converting the nvarchar value ''1392/02/11'' to data type int.
推荐答案
您是否尝试过:
Have you tried:
SELECT [R-Date] FROM Reg WHERE (CONVERT(INT,REPLACE(Reg.[R-Date], '/', '') )) BETWEEN 13920201 AND 13920222
但该值看起来更像是日期而不是整数。你想在这做什么?是不是数据类型的日期完全是一个更好的主意?
But that value looks more date-ish than integer. What are you trying to do here? Wouldn''t date datatypes be a better idea altogether?
这篇关于在从字符串到int的转换中使用escape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文