Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLɾ³ýÖ¸¶¨×Ö¶ÎÎÊÌâ

¸üÐÂÏÂÎÊÌ⣺
񡜧TBL_Info
×ֶΣº
    infoId int
    title  varchar(20)
    Content  text
    byUser  varchar(20)
    createTime datetime
1¡¢ÈçºÎɾ³ý±íÖÐÊý¾ÝÏàͬµÄÊý¾ÝÄØ£¿£¨Ö÷¼ü³ýÍ⣩
2¡¢ÈçºÎɾ³ýÊý¾Ý±íÖÐij¸ö×Ö¶ÎÊý¾ÝÏàͬµÄÊý¾ÝÄØ(±ÈÈçtitle£ºÉ¾³ýËùÓÐtitleÏàͬµÄÊý¾Ý)£¿
3¡¢ÈçºÎͳ¼Æ±íÖÐtitleÏàͬÊý¾ÝµÄÊýÄ¿£¿
--1
--1.1Ïàͬʱ±£Áô×îСµÄinfoId
delete TBL_Info from TBL_Info t where infoId not in (select min(id) from infoId where title = t.title and Content = t.Content and byUser = t.byUser and createTime = t.createTime)
--1.1Ïàͬʱ±£Áô×î´óµÄinfoId
delete TBL_Info from TBL_Info t where infoId not in (select max(id) from infoId where title = t.title and Content = t.Content and byUser = t.byUser and createTime = t.createTime)
--2
delete from TBL_Info where title in (select title from TBL_Info group by title having count(1) > 1)
--3
select title , count(1) from TBL_Info group by title
select title , count(*) from TBL_Info group by title
select title , count(title) from TBL_Info group by title
--¹¦ÄܸÅÊö:ɾ³ýÖظ´¼Ç¼
ÔÚ¼¸Ç§Ìõ¼Ç¼Àï,´æÔÚ×ÅЩÏàͬµÄ¼Ç¼,ÈçºÎÄÜÓÃSQLÓï¾ä,ɾ³ýµôÖظ´µÄÄØ?лл!
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select  peopleId  from  people  group  by  peopleId  having  count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼
delete from people
where peopleId  in (select  peopleId  from people  group  by  peopleId  having  count(peopleId) > 1)
and rowid not in (select min(rowid) from  people  group by peopleId  having count(peopleId )>1)
3¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¨¶à¸ö×ֶΣ©
select * from vitae a
where (a.peopleId,a.seq) in  (select peopleId,seq from vitae group by peopleId,seq  having count(*) > 1)
4¡¢É¾³ý±íÖж


Ïà¹ØÎĵµ£º

SQL SERVER ½Çɫ˵Ã÷£¨Õª×ÔMSDN£©


·þÎñÆ÷¼¶±ð½ÇÉ«
Ϊ±ãÓÚ¹ÜÀí·þÎñÆ÷ÉϵÄȨÏÞ£¬SQL Server ÌṩÁËÈô¸É“½ÇÉ«”£¬ÕâЩ½ÇÉ«ÊÇÓÃÓÚ·Ö×éÆäËûÖ÷ÌåµÄ°²È«Ö÷Ìå¡£“½ÇÉ«”ÀàËÆÓÚ Microsoft Windows ²Ù×÷ϵͳÖеē×锡£
·þÎñÆ÷¼¶½ÇÉ«Ò²³ÆΪ“¹Ì¶¨·þÎñÆ÷½ÇÉ«”£¬ÒòΪÄú²»ÄÜ´´½¨ÐµķþÎñÆ÷¼¶½ÇÉ«¡£·þÎñÆ÷¼¶½ÇÉ«µÄȨÏÞ×÷Óà ......

sqlÖнØÈ¡ºÍËã³ö×Ö·û´®µÄ³¤¶È

et ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[Get_StrArrayLength]
(
 @str varchar(1024),  --Òª·Ö¸îµÄ×Ö·û´®
 @split varchar(10)  --·Ö¸ô·ûºÅ
)
returns int
as
begin
 declare @location int
 declare @start int
 declare @length int
&nbs ......

sqlÖзָî×Ö·û´®

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[Get_StrArrayStrOfIndex]
(
 @str varchar(1024),  --Òª·Ö¸îµÄ×Ö·û´®
 @split varchar(10),  --·Ö¸ô·ûºÅ
 @index int --È¡µÚ¼¸¸öÔªËØ
)
returns varchar(1024)
as
begin
 declare @location int
 de ......

Sql ²éѯ¼¼ÇÉ Ä³Àý ¹ØÓÚinµÄÅÅÐò

  ÔÚÓÐʱºòʹÓÃinÓï¾ä²éѯµÄʱºò,inÓï¾äÖкܶàÏî,Èç15Ï×Ô¼ºÍ¬Ê±ÏëÈòéѯ³öÀ´½á¹ûÄܹ»°´ÕÕinÓï¾äÖиÃ×Ö¶Î˳Ðò²éѯ³öÀ´¡£
 ¶øSql ServerÊÇĬÈÏ°´ÕÕ×Ô¼ºµÄ˳ÐòÅÅÁгöÀ´µÄ£¬ËùÒÔÒ»¶¨»á°Ñ½á¹û¼¯ÖØÐÂÅÅÐòµÄ¡£
¶øÈç¹ûʹÓÃcase whenµÄ·½·¨ËäÈ»ºÜ·±Ëö£¬µ«Ò²ÊÇ¿ÉÒÔʵÏÖµÄ
 
 
select item_code,apply_dep ......

asp.netÈçºÎÁ¬½Ósql server2000Êý¾Ý¿â

¡ïAsp.netÈçºÎÁ¬½ÓSQL Server2000Êý¾Ý¿â¡ï
 
´ó¼ÒºÃ,ÒÔÏÂÊÇÓйØASP.netÁ¬½ÓSQL Server2000Êý¾Ý¿âµÄÀý³Ì£¬
ÔÚÕâÀïºÍ´ó¼Ò·ÖÏíһϣº
Asp.netÁ¬½ÓSQL Server2000Êý¾Ý¿âÀý³ÌÏê½â: 
<%@ Import Namespace="System.Data" %> 
<%@ Import NameSp ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ