SQL Server类语句添加getdate +通配符



我想用这个函数替换like语句

select year(GetDate()) and add '%'
你能告诉我怎么做吗?下面是SQL语句:
Select *
from table a 
where = month like '2023%'

我期望与SQL语句相同的结果,但替换为year(getdate())语句。

首先,我不确定在这种情况下字符串比较是否有意义。
然而,我认为你正在寻找这样的东西(转换为nvarchar并附加%):

convert(nvarchar(4),year(GetDate())) +'%'

完整查询:

Select *
from table a 
where month like convert(nvarchar(4),year(GetDate())) +'%'

最新更新