DECLARE @var VARCHAR(50)
SET @var ='116.404556|39.915156'
方式一:
SELECT
CASE WHEN ISNULL(@var,'') <> '' THEN LEFT(@var,CHARINDEX('|',@var)-1) ELSE '' END Longitude
,CASE WHEN ISNULL(@var,'') <> '' THEN RIGHT(@var,CHARINDEX('|',@var)-2) ELSE '' END Latitude
,@var Longitude_Latitude
方式二:
SELECT
CASE WHEN ISNULL(@var,'') <> '' THEN SUBSTRING(@var,1,CHARINDEX('|',@var,1)-1) ELSE '' END AS Longitude
,CASE WHEN ISNULL(@var,'') <> '' THEN SUBSTRING(@var,CHARINDEX('|',@var,1)+1,LEN(@var)-CHARINDEX('|',@var,1)) ELSE '' END AS Latitude
,@var Longitude_Latitude