摘要:如何將一整串地址,分出縣、市、區
CREATE TABLE MEM (ADDR NVARCHAR(1000))
INSERT INTO MEM(ADDR) VALUES ('台北市南港區三重路xx號xx樓' )
INSERT INTO MEM(ADDR) VALUES ('台北市中正區xx路xx號xx樓' )
CREATE TABLE Country ( CityAREA NVARCHAR(20))
INSERT INTO Country(CityAREA) VALUES('台北市南港區')
INSERT INTO Country(CityAREA) VALUES('桃園市桃園區')
SELECT *
FROM MEM A INNER JOIN Country B
ON CHARINDEX(B.CityAREA,A.ADDR)>0
DROP TABLE MEM
DROP TABLE Country