id address
-----------------------------------------------
1 hyderabad,madhapur,patrika nagar 500072
2 telangana,uppal, ragive gand nagar,517456
3 usa,verginea,va,123093
4 america,new york
5 india
输出应为:
1 hyderabad,madhapur,
patrika nagar 500072
2 telangana,uppal,
ragive gand nagar,517456
3 usa,verginea,
123093
4 america,new york
5 india
答案 0 :(得分:0)
这或许?
DECLARE @string varchar(8000) =
'id address 1 hyderabad,madhapur,patrika nagar 500072 2 telangana,uppal, ragive gand nagar,517456 3 usa,verginea,va,123093 4 america,new york 5 india'
SELECT newstring = SUBSTRING(@string, d.pos+1, 8000)
FROM (VALUES (CHARINDEX(' ',@string, (CHARINDEX(' ',@string)+1)))) d(pos);
返回
1 hyderabad,madhapur,patrika nagar 500072 2 telangana,uppal, ragive gand nagar,517456 3 usa,verginea,va,123093 4 america,new york 5 india