首页 > 解决方案 > SQL server Rex 获取通配符中的字符串

问题描述

例如,我有一个带有表名和架构的字符串,例如:

[dbo].[statistical]

如何statistical从这个字符串中只获取表名?

标签: sqlsql-serverstring

解决方案


这是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'

推荐阅读