确保序列的一种选择是使用一些 XML
例子
Declare @YourTable table (ID int, SomeCol varchar(100))
Insert into @YourTable Values
(1,'Some text that needs to be parsed')
,(2,'Only three words')
Select A.ID
,Pos5 = cast('<x>' + replace(SomeCol,' ','</x><x>')+'</x>' as xml).value('/x[5]','varchar(50)')
From @YourTable A
Run Code Online (Sandbox Code Playgroud)
退货
ID Pos5
1 to
2 NULL
Run Code Online (Sandbox Code Playgroud)