我的數據看起來像這樣:如何檢索SQL Server中字符串的唯一特定部2012
PrimISOcodeGL
99507 - Swimming Pools – installation & service – below ground - 1799 - Hazard 3
18501 - Supermarkets - 5411 - Hazard 1
91580 - Contractors Executive Supervisors - 1541 - Hazard 2
10073 - Automobile Sales, Repair or Service Shop - 7539 - Hazard 2
我怎麼只能檢索第一和第二之間的名字「 - 」?
因此,它應該是這樣的:
PrimISOcodeGL
Swimming Pools
Supermarkets
Contractors Executive Supervisors
Automobile Sales, Repair or Service Shop
我想使用的功能像CHARINDEX
,LTRIM
,RTRIM
,LEN
查找第一CHARINDEX。從那裏拿字符串+1直到下一個連字符的charindex。因此,這將是以charindex形式傳入的數字的子字符串。 – Amit