在AP裡處理吧,為什麼堅持用SQL呢
迁移数据
@小阿雄:
TSQL?
@小阿雄:
DECLARE @MaxLen INT = 0
SELECT @MaxLen = MAX(LEN(kmdm))
FROM your_table
WHILE (@MaxLen > 0)
BEGIN
SELECT *
INTO #Temp
FROM your_table
WHERE LEN(kmdm) = @MaxLen
AND NOT EXISTS(SELECT 1 FROM #Temp WHERE kmdm LIKE kmdm + '%')
SET @MaxLen = @MaxLen - 2
END
SELECT * FROM @Temp
細節你再調整
@RosonJ: 好使,感谢