转载

SQL Server 截取两个固定字符之间的字符串(案例)

网上的问题:

 

 


参考这篇《函数PARSENAME使用和截取字符串https://www.cnblogs.com/insus/p/10958452.html 的方法:

 

DECLARE @str VARCHAR(1000)='||MO21|TMT-0080|1|10'

SET @str = REPLACE(STUFF(@str,1,2,''),'|','.')

SELECT PARSENAME(@str,3)

    --PARSENAME(@str,4) AS [TABLE_CATALOG],
    --PARSENAME(@str,3) AS [TABLE_SCHEMA],
    --PARSENAME(@str,2) AS [TABLE_NAME],
    --PARSENAME(@str,1) AS [COLUMN_NAME]
GO
Source Code

 

正文到此结束
本文目录