sql - SQL server Rex 获取通配符中的字符串
问题描述
例如,我有一个带有表名和架构的字符串,例如:
[dbo].[statistical]
如何statistical
从这个字符串中只获取表名?
解决方案
这是PARSENAME
用于:
SELECT PARSENAME('[dbo].[statistical]', 1)
SELECT PARSENAME('[adventureworks].[dbo].[statistical]', 1)
SELECT PARSENAME('[adventureworks]..[statistical]', 1)
SELECT PARSENAME('[statistical]', 1)
SELECT PARSENAME('dbo.statistical', 1)
-- all examples return 'statistical'