SQL依据特殊符号分批截取字符串(案例)

网上的问题:

 

 

下面是Insus.NET的解决办法,仅供参考。

CREATE TABLE #temp([Source] NVARCHAR(100))
INSERT INTO #temp([Source]) VALUES 
    ('2012-04-27 16:49:24$1$2'),
    ('2012-04-27 17:04:26$2$2'),
    ('2012-04-27 17:18:58$2$2926180')


SELECT [Source],
        PARSENAME(REPLACE([Source],'$','.'),3) AS [日期],
        PARSENAME(REPLACE([Source],'$','.'),2) AS [考勤机号],
        PARSENAME(REPLACE([Source],'$','.'),1) AS [员工编号]
FROM #temp
Source Code

 

有关PARSENAME函数,这篇《函数PARSENAME使用和截取字符串https://www.cnblogs.com/insus/p/10958452.html

 

posted @ 2019-06-01 13:02  Insus.NET  阅读(4107)  评论(0编辑  收藏  举报