SQLɾ³ýÖØ¸´Êý¾Ý
Ò»¡¢¾ßÓÐÖ÷¼üµÄÇé¿ö
I.¾ßÓÐΨһÐÔµÄ×Ö¶Îid(ΪΨһÖ÷¼ü)
delete Óû§±í
where id not in
(
select max(id) from Óû§±í group by col1,col2,col3...
)
group by ×Ó¾äºó¸úµÄ×ֶξÍÊÇÄãÓÃÀ´ÅжÏÖØ¸´µÄÌõ¼þ£¬ÈçÖ»ÓÐcol1£¬
ÄÇôֻҪcol1×Ö¶ÎÄÚÈÝÏàͬ¼´±íʾ¼Ç¼Ïàͬ¡£
II.¾ßÓÐÁªºÏÖ÷¼ü
¼ÙÉècol1+','+col2+','...col5 ΪÁªºÏÖ÷¼ü
£¨ÕÒ³öÏàͬ¼Ç¼£©
select * from Óû§±í where col1+','+col2+','...col5 in
(
select max(col1+','+col2+','...col5) from Óû§±í
group by col1,col2,col3,col4
having count(*)>1
)
group by ×Ó¾äºó¸úµÄ×ֶξÍÊÇÄãÓÃÀ´ÅжÏÖØ¸´µÄÌõ¼þ£¬
ÈçÖ»ÓÐcol1£¬ÄÇôֻҪcol1×Ö¶ÎÄÚÈÝÏàͬ¼´±íʾ¼Ç¼Ïàͬ¡£
»òÕߣº
£¨ÕÒ³öÏàͬ¼Ç¼£©
select * from Óû§±í where exists (select 1 from Óû§±í x where Óû§±í.col1 = x.col1 and
Óû§±í.col2= x.col2 group by x.col1,x.col2 having count(*) >1)
III:ÅжÏËùÓеÄ×Ö¶Î
select * into #aa from Óû§±í group by id1,id2,....
delete Óû§±í
insert into Óû§±í select * from #aa
¶þ¡¢Ã»ÓÐÖ÷¼üµÄÇé¿ö
I.ÓÃÁÙʱ±íʵÏÖ
select identity(int,1,1) as id,* into #temp from Óû§±í
delete #temp
where id not in
(
select max(id) from # group by col1,col2,col3...
)
delete Óû§±í ta
inset into ta(...) select ..... from #temp
II.Óøıä±í½á¹¹£¨¼ÓÒ»¸öΨһ×ֶΣ©À´ÊµÏÖ
alter Óû§±í add newfield int identity(1,1)
delete Óû§±í
where newfield not in
(
select min(newfield) from Óû§±í group by ³ýnewfieldÍâµÄËùÓÐ×Ö¶Î
)
alter Óû§±í drop column newfield
Ïà¹ØÎĵµ£º
SQL Server°²×°Îļþ¹ÒÆð:
ÔÚÖØÐ°²×°Ö÷SQLServer2000ʱ»òÊÇ´ò²¹¶¡Ê±,×ÜÊÇ»áÓöµ½SQLServer°²×°Îļþ¹ÒÆð¡£
ÔÚÔËÐд°¿ÚÊäÈëregedit£¬´ò¿ª×¢²á±í±à¼Æ÷£¬ÔÚHKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session ManagerÖÐÕÒµ½PendingFileRenameOperations£¬É¾³ý¸Ã¼üÖµ£¨Õâ¸ö¼üÖµÊǰ²×°³ÌÐòÔݹÒÏîÄ¿£¬Ö»ÒªÕÒµ½¶ÔÓ¦µÄÓ¦Óó ......
3¡£±íÄÚÈÝÈçÏÂ
¡¡¡¡-----------------------------
¡¡¡¡ID LogTime
¡¡¡¡1 2008/10/10 10:00:00
¡¡¡¡1 2008/10/10 10:03:00
¡¡¡¡1 2008/10/10 10:09:00
¡¡¡¡2 2008/10/10 10:10:00
¡¡¡¡2 2008/10/10 10:11:00
¡¡¡¡......
¡¡¡¡-----------------------------
¡¡¡¡ÇëÎʸ÷λ¸ßÊÖ£¬ÈçºÎ²éѯµÇ½ʱ¼ä¼ä¸ô²»³¬ ......
³õ´ÎʹÓÃpb10µÄÅóÓÑÎÞ·¨Ë³ÀûÁ¬½Óµ½sql server£¬Ò»·½ÃæÃ»ÓÐÁËmssql serverרÓýӿÚÁË£¬ÁíÒ»·½ÃæÊý¾Ý¿â¹ÜÀíϵͳ(DBMS)»»³ÉÁË“OLE DB”£¬ÅäÖÃÆðÀ´Óе㲻˳ÊÖ£¡ÏÂÃæ¾ÍÀ´½éÉÜpb10ÖÐÓÃOLE DBÁ¬½Ósql 2000Êý¾Ý¿â¡£
ÔÚ°²×°pb10µÄʱºòÑ¡Ôñcustom/full·½Ê½°²×°£¨Ä¬Èϵݲװ·½Ê½²»»á°²×°ole db½Ó¿Ú£©£¬next£¡·Èç¹ûÄãûÓа ......
´ËÎÊÌâÕÛÌÚ°ëÌì,googleÒ²ËÑË÷ÁË,ÍøÉϺܶàÅóÓÑÒ»°ã×öµ½µÚ¶þ²½²»³É¹¦,ÎÒÒ²²îµã·ÅÆúÁË.×îºóͨ¹ýµÚÈý²½Á¬½Ó³É¹¦ÁË.
1.·À»ðǽÔÊÐí1433
2.ÅäÖù¤¾ßÀïµÄSQL Server ÅäÖùÜÀíÆ÷.´ò¿ªºó,¿ªÆôÓÒ±ßÈý¸öÐÒé.²¢¶Ôtcp/ipÈçÏÂÅäÖÃ
3.ÍøÉϴ󲿷Ö×öµ½µÚ¶þ°æÖØÆôsql server·þÎñ,ÈÔÈ»ÎÞЧ.Æäʵ,ÐèÒªÐÞ¸ÄÁ¬½Ó×Ö·û´®.Ö¸¶¨ÎÒÃÇÅäÖõĶ ......