This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / what is the best way split the column of string into rows of string with T-SQL?eg. table as:
Id Detail
1 asd;fad;
2 ads;fsa;df2;
3 adf;
output need to be:
id detail
1 asd;
1 fad;
2 ads;
2 fsa;
2 df2;
3 adf;
Thanks.
-sunday8(每个年头都有新的梦景);
2013-5-8
{166}
(#8190445@0)
-
Use xmlDECLARE @temp TABLE (ID INT, xCol xml)
INSERT @temp
SELECT ID, CAST(REPLACE(('<r>'+REPLACE(Detail, ';', ';</r><r>')+'</r>'), '<r></r>', '') AS XML) xCol
FROM YourTable
SELECT ID, n.r.value('.', 'varchar(50)') Detail FROM @temp cross apply xCol.nodes('r') as n(r)
-deep_blue(BLUE);
2013-5-8
{291}
(#8190993@0)
-
你是不当经理啊, 有一定水平.
-kaixin8899(kaixin);
2013-6-9
(#8238683@0)
-
当然不是经理。您想找工的话,帮不上忙。听您的口气倒是经理。
-deep_blue(BLUE);
2013-6-9
(#8238863@0)
-
你想多了, 单纯夸你一下. 不用你找工作, 我在职.
-kaixin8899(kaixin);
2013-6-10
(#8239205@0)
-
开个玩笑 - kaixin 一下。 别当真。
-deep_blue(BLUE);
2013-6-10
(#8239299@0)