2013-10-23 110 views

回答

4

您可以使用SUBSTRING做到這一點:

SELECT 
    SUBSTRING(TRN02, 0, CHARINDEX('-', TRN02)) AS [First] 
    SUBSTRING(TRN02, CHARINDEX('-', TRN02) + 1, LEN(TRN02)) AS [Second] 
FROM TABLE 
0
SELECT LEFT(details, CHARINDEX ('-', TRN02) - 1), 
     SUBSTRING(details, CHARINDEX ('-', TRN02) + 1, 100) 
    FROM Your_table 
+0

Thnaks好友... – Naveen

1

只是另一種方式使用LEFTRIGHT -

SELECT LEFT(TRN02, CHARINDEX('-', TRN02) - 1) [before_delim], 
     RIGHT(TRN02, LEN(TRN02) - CHARINDEX('-', TRN02)) [after_delim] 
FROM your_table 
相關問題