【问题标题】:SQL Server with RegExp带有正则表达式的 SQL Server
【发布时间】:2015-12-22 20:41:56
【问题描述】:

使用正则表达式查找 T-SQL 查询以从示例数据中选择具有今天日期的记录,如下所示:

样本数据格式:

[DAILY|MASTER|SUPER]-Integer-Date(yyyymmdd)

DAILY-60-20151216
DAILY-61-20151217
SUPER-62-20151218
DAILY-63-20151219
MASTER-64-20151220
DAILY-65-20151221
SUPER-66-20151222
DAILY-67-20151222

【问题讨论】:

    标签: sql sql-server


    【解决方案1】:

    您不需要正则表达式,只需 right() 函数:

    where cast(right(data, 8) as date) = cast(getdate() as date)
    

    【讨论】:

      猜你喜欢
      • 2012-11-06
      • 1970-01-01
      • 2010-12-30
      • 2016-05-05
      • 2010-09-16
      • 1970-01-01
      • 2022-08-03
      • 1970-01-01
      相关资源
      最近更新 更多