如何转换不合理存储的表 多值依赖

前端之家收集整理的这篇文章主要介绍了如何转换不合理存储的表 多值依赖前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
CREATE TABLE #t ( linkreturnid INT,id INT ) SELECT LinkReturnID,id INTO #t0 FROM CallCentre.cc.BackChangeApply WHILE EXISTS ( SELECT LinkReturnID,id FROM #t0 WHERE LinkReturnID LIKE '%,' ) BEGIN UPDATE #t0 SET LinkReturnID = RIGHT(LinkReturnID,LEN(LinkReturnID) - PATINDEX('%,%',LinkReturnID)) OUTPUT LEFT(deleted.LinkReturnID,PATINDEX('%,deleted.LinkReturnID) - 1),deleted.id INTO #t WHERE LinkReturnID LIKE '%,' END SELECT * FROM #t DROP TABLE #t,#t0

猜你在找的设计模式相关文章