
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
	<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head><card id="MainCard" title="&#x6B22;&#x8FCE;&#x5149;&#x4E34;"><p><a href="wap.asp">&#x6728;&#x5B50;&#x5C4B;</a><br/>&nbsp;</p><p><b>&#x6807;&#x9898;&#x3A;</b> &#x56FD;&#x5BB6;&#x7EDF;&#x8BA1;&#x5C40;&#x53BF;&#x53CA;&#x53BF;&#x4EE5;&#x4E0A;&#x884C;&#x653F;&#x533A;&#x5212;&#x5BFC;&#x5165;&#x53;&#x51;&#x4C;&#x20;&#x53;&#x65;&#x72;&#x76;&#x65;&#x72;&#x6B65;&#x9AA4;</p><p><b>&#x4F5C;&#x8005;&#x3A;</b> &#x64;&#x6E;&#x61;&#x77;&#x6F;</p><p><b>&#x65E5;&#x671F;&#x3A;</b> &#x32;&#x30;&#x31;&#x32;&#x2D;&#x31;&#x32;&#x2D;&#x33;&#x31;&#x20;&#x31;&#x32;&#x3A;&#x35;&#x34;&#x20;&#x41;&#x4D;</p><p><b>&#x5206;&#x7C7B;&#x3A;</b> <a href="wap.asp?do=showLog&amp;cateID=2">&#x5176;&#x4ED6;</a></p><p><b>&#x5185;&#x5BB9;&#x3A;</b> &#x4E00;&#x3001;&#x9700;&#x6C42;<br/>&#x5C06;&#x56FD;&#x5BB6;&#x7EDF;&#x8BA1;&#x5C40;&#x53D1;&#x5E03;&#x7684;&#x53BF;&#x53CA;&#x53BF;&#x4EE5;&#x4E0A;&#x884C;&#x653F;&#x533A;&#x5212;&#x4EE3;&#x7801;&#x5BFC;&#x5165;SQL Server&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x6700;&#x7EC8;&#x8868;&#x683C;&#x5F0F;&#xFF1A;<br/>&#x590D;&#x5236;&#x5185;&#x5BB9;&#x5230;&#x526A;&#x8D34;&#x677F; &#x7A0B;&#x5E8F;&#x4EE3;&#x7801;cr&#101;ate table City<br/>(<br/>&#160;&#160;&#160;&#160;Id int identity(1,1) primary key,<br/>&#160;&#160;&#160;&#160;Name nvarchar(20),<br/>&#160;&#160;&#160;&#160;ParentId int<br/>)<br/>&#x4E8C;&#x3001;&#x5BFC;&#x5165;&#x6B65;&#x9AA4;<br/>1.&#x590D;&#x5236;&#x6700;&#x65B0;&#x53BF;&#x53CA;&#x53BF;&#x4EE5;&#x4E0A;&#x884C;&#x653F;&#x533A;&#x5212;&#x4EE3;&#x7801;&#xFF08;&#x622A;&#x6B62;2011&#x5E74;10&#x6708;31&#x65E5;&#xFF09;&#x7C98;&#x8D34;&#x5230;&#x8BB0;&#x4E8B;&#x672C;&#xFF1B;<br/>2.&#x53BB;&#x6389;&#x5317;&#x4EAC;&#x3001;&#x91CD;&#x5E86;&#x3001;&#x5929;&#x6D25;&#x3001;&#x4E0A;&#x6D77;&#x56DB;&#x4E2A;&#x76F4;&#x8F96;&#x5E02;&#x7684;&#x5E02;&#x8F96;&#x533A;&#x548C;&#x53BF;&#xFF0C;&#x5E95;&#x4E0B;&#x884C;&#x653F;&#x533A;&#x63D0;&#x4E00;&#x7EA7;(&#x53BB;&#x6389;&#x4E24;&#x4E2A;&#x7A7A;&#x683C;)&#xFF1B;<br/>3.&#x53BB;&#x6389;&#x6CB3;&#x5357;&#x7701;&#x3001;&#x6E56;&#x5317;&#x7701;&#x3001;&#x6D77;&#x5357;&#x7701;&#x3001;&#x65B0;&#x7586;&#x7EF4;&#x543E;&#x5C14;&#x81EA;&#x6CBB;&#x533A;&#x56DB;&#x4E2A;&#x7701;&#x76F4;&#x8F96;&#x53BF;&#x7EA7;&#x884C;&#x653F;&#x533A;&#x5212;&#xFF0C;&#x5E95;&#x4E0B;&#x884C;&#x653F;&#x533A;&#x63D0;&#x4E00;&#x7EA7;(&#x53BB;&#x6389;&#x4E24;&#x4E2A;&#x7A7A;&#x683C;)&#xFF1B;<br/>4.&#x66FF;&#x6362;&#34; &#34;(&#x53BB;&#x6389;&#x4E24;&#x4E2A;&#x7A7A;&#x683C;)&#x4E3A;,&#xFF0C;&#x4FDD;&#x5B58;&#x4E3A;city.csv&#xFF0C;&#x5728;Excel&#x4E2D;&#x6253;&#x5F00;&#x540E;&#x518D;&#x53E6;&#x5B58;&#x4E3A;city.xls&#xFF1B;<br/>5.&#x6253;&#x5F00;SQL Server Management Studio&#xFF0C;&#x5C06;city.xls&#x6570;&#x636E;&#x5BFC;&#x5165;&#x5230;c1&#x8868;&#xFF0C;&#x5B57;&#x6BB5;&#x4E3A;f1,f2,f3,f4&#xFF1B;<br/>6.&#x8FD0;&#x884C;&#x4EE5;&#x4E0B;sql&#x8BED;&#x53E5;&#x5B8C;&#x6210;&#x8F6C;&#x6362;&#xFF1A;<br/>&#x590D;&#x5236;&#x5185;&#x5BB9;&#x5230;&#x526A;&#x8D34;&#x677F; &#x7A0B;&#x5E8F;&#x4EE3;&#x7801;--&#x5BFC;&#x5165;&#x5230;c2<br/>cr&#101;ate table c2<br/>(<br/>&nbsp;&nbsp;&nbsp;&nbsp;id int identity(1,1) primary key,<br/>&nbsp;&nbsp;&nbsp;&nbsp;f1 int,<br/>&nbsp;&nbsp;&nbsp;&nbsp;f2 nvarchar(20),<br/>&nbsp;&nbsp;&nbsp;&nbsp;f3 nvarchar(20),<br/>&nbsp;&nbsp;&nbsp;&nbsp;f4 nvarchar(20),<br/>&nbsp;&nbsp;&nbsp;&nbsp;parentid int<br/>)<br/>ins&#101;rt into c2(f1,f2,f3,f4,parentid)<br/>sel&#101;ct f1,f2,f3,f4,0 from c1 o&#114;der by f1<br/>--&#x6570;&#x636E;&#x6574;&#x7406;<br/>up&#100;ate c2 set parentid=(sel&#101;ct max(id) from c2 t2 wh&#101;re t2.id&lt;c2.id and not t2.f3 is null) wh&#101;re not f4 is null<br/>up&#100;ate c2 set parentid=(sel&#101;ct max(id) from c2 t2 wh&#101;re t2.id&lt;c2.id and not t2.f2 is null) wh&#101;re not f3 is null<br/>up&#100;ate c2 set parentid=0 wh&#101;re not f2 is null<br/>--&#x6700;&#x7EC8;&#x6570;&#x636E;<br/>cr&#101;ate table City<br/>(<br/>&nbsp;&nbsp;&nbsp;&nbsp;Id int identity(1,1) primary key,<br/>&nbsp;&nbsp;&nbsp;&nbsp;Name nvarchar(20),<br/>&nbsp;&nbsp;&nbsp;&nbsp;ParentId int<br/>)<br/>ins&#101;rt into City(Name,ParentId)<br/>sel&#101;ct isnull(f2,&#39;&#39;)+isnull(f3,&#39;&#39;)+isnull(f4,&#39;&#39;),parentid from c2<br/>--&#x9A8C;&#x8BC1;<br/>sel&#101;ct * from c2 wh&#101;re parentid is null<br/>sel&#101;ct * from City left join c2 on City.Id=c2.id wh&#101;re City.ParentId&lt;&gt;c2.parentid</p><p> + <a href="#CommentCard">&#x67E5;&#x770B;&#x5F53;&#x524D;&#x65E5;&#x5FD7;&#x8BC4;&#x8BBA;</a> (0)</p><p>&nbsp;<br/><br/><a href="wap.asp?do=Login">&#x767B;&#x5F55;</a></p><p><br/>&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;</p><p><a href="wap.asp">&#x6728;&#x5B50;&#x5C4B;</a></p><p><a href="http://www.pjhome.net/wap.asp">PJBlog3&nbsp;v3.2.9.518</a>&nbsp;Inside.</p><p>Processed&nbsp;In&nbsp;0.047&nbsp;ms</p><do type="prev" label="&#x8FD4;&#x56DE;"><prev/></do></card><card id="postCommentCard"><p><b>&#x6807;&#x9898;&#x3A;</b> <a href="#MainCard">&#x56FD;&#x5BB6;&#x7EDF;&#x8BA1;&#x5C40;&#x53BF;&#x53CA;&#x53BF;&#x4EE5;&#x4E0A;&#x884C;&#x653F;&#x533A;&#x5212;&#x5BFC;&#x5165;&#x53;&#x51;&#x4C;&#x20;&#x53;&#x65;&#x72;&#x76;&#x65;&#x72;&#x6B65;&#x9AA4;</a></p><p><br/>你没有权限发表评论</p><p><br/>&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;</p><p><a href="wap.asp">&#x6728;&#x5B50;&#x5C4B;</a></p><p><a href="http://www.pjhome.net/wap.asp">PJBlog3&nbsp;v3.2.9.518</a>&nbsp;Inside.</p><p>Processed&nbsp;In&nbsp;0.047&nbsp;ms</p><do type="prev" label="&#x8FD4;&#x56DE;"><prev/></do></card><card id="CommentCard"><p>&#x6682;&#x65E0;&#x8BC4;&#x8BBA;</p><p><a href="#MainCard">&#x8FD4;&#x56DE;</a></p><p><br/>&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;</p><p><a href="wap.asp">&#x6728;&#x5B50;&#x5C4B;</a></p><p><a href="http://www.pjhome.net/wap.asp">PJBlog3&nbsp;v3.2.9.518</a>&nbsp;Inside.</p><p>Processed&nbsp;In&nbsp;0.047&nbsp;ms</p><do type="prev" label="&#x8FD4;&#x56DE;"><prev/></do></card>
</wml>
