我有一个名为 Types 的表,数据如下:
Item_Name
Hardware \ Hardware Laptop \ Display
Application \ Application Configuration Request
Application \ Application File Request
Application
我试图将它们分成 3 个不同的列。所以尝试通过以下查询来做到这一点:
select parsename(replace([Item_Name],'\','.'),3) as First,
parsename(replace([Item_Name],'\','.'),2) as Second,
parsename(replace([Item_Name],'\','.'),1) as third
from dbo.Types
但我没有得到我想要的输出的确切结果:
First Second Third
Hardware Hardware Laptop Display
Application Application Configuration Request NULL
Application Application File Request NULL
Application NULL NULL
但我得到的输出为:
First Second Third
Hardware Hardware Laptop Display
NULL Application Application Configuration Request
NULL Application Application File Request
NULL NULL Application