SQLÖظ´¼Ç¼²éѯ
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¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¨¶à¸ö×ֶΣ©£¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼
delete from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having
count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
5¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¨¶à¸ö×ֶΣ©£¬²»°üº¬rowid×îСµÄ¼Ç¼
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having
count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
Ïà¹ØÎĵµ£º
ÒÔÏÂʵÏÖ¸´ÖƲ½Ö裨ÒÔ¿ìÕÕ¸´ÖÆΪÀý£©
ÔËÐÐƽ̨SQL SERVER 2005
Ò»¡¢×¼±¸¹¤×÷£º
1£®½¨Á¢Ò»¸ö WINDOWS Óû§£¬ÉèÖÃΪ¹ÜÀíԱȨÏÞ£¬²¢ÉèÖÃÃÜÂ룬×÷Ϊ·¢²¼¿ìÕÕÎļþµÄÓÐЧ·ÃÎÊÓû§¡£
2£®ÔÚSQL SERVERÏÂʵÏÖ·¢²¼·þÎñÆ÷ºÍ¶©ÔÄ·þÎñÆ÷µÄͨÐÅÕý³££¨¼´¿ÉÒÔ»¥·Ã£©¡£´ò¿ª1433¶Ë¿Ú£¬ÔÚ·À»ðǽÖÐÉèÌØÀý
3£®ÔÚ·¢²¼·þÎñÆ÷ÉϽ¨Á¢Ò»¸ö ......
SQL Server .NET Framework Êý¾ÝÌṩ³ÌÐò (SqlClient) Ìṩ¾ÛºÏº¯Êý¡£¾ÛºÏº¯Êý¶ÔÒ»×éÊäÈëÖµÖ´ÐмÆËã²¢·µ»ØÒ»¸öÖµ¡£ÕâЩº¯ÊýλÓÚ SqlServer ÃüÃû¿Õ¼äÖУ¬¸ÃÃüÃû¿Õ¼äÔÚÄúʹÓà SqlClient ʱ¿ÉÓá£Ìṩ³ÌÐòµÄÃüÃû¿Õ¼äÊôÐÔʹʵÌå¿ò¼Ü¿ÉÒÔÈ·¶¨´ËÌṩ³ÌÐò¶ÔÌض¨¹¹Ô죨ÈçÀàÐͺͺ¯Êý£©Ê¹ÓÃÄĸöǰ׺¡£
ϱíÏÔʾ SqlClient ¾ÛºÏº¯Êý¡£ ......
select getdate()
ÊÇÏÔʾµ±Ç°ÏµÍ³Ê±¼ä£¬Êä³öµÄÈÕÆÚ¸ñʽÓë±¾»úÈÕÆÚ¸ñʽÓйأ¬¼ÙÈëÄãÏëÔÚʲôÇé¿ö϶¼ÏÔʾ³É2006-12-15 10:37:00ÕâÖÖÐÎʽÔòÐèҪת»»Ò»ÏÂ
select convert(varchar(30),getdate(),20)
ÏÔʾÊÇÐÇÆÚ¼¸µÄÓï¾äÊÇ
select datename(weekday,getdate())
ÈÕÆÚ¼ÓÐÇÆڵĻ°Ö±½Ó¼ÓÔÚÒ»¿é¾Í¿ÉÒÔÁË
select convert(varcha ......
SQL Server 2005 Áª»ú´ÔÊ飨2008 Äê 11 Ô£©
SQL Server 2005 µÄĬÈÏʵÀýºÍÃüÃûʵÀýµÄÎļþλÖÃ
¸üÐÂÈÕÆÚ£º 2005 Äê 12 Ô 5 ÈÕ
Microsoft SQL Server 2005 µÄ°²×°°üº¬Ò»¸ö»ò¶à¸öµ¥¶ÀµÄʵÀý¡£ÎÞÂÛÊÇĬÈϵĻ¹ÊÇÃüÃûµÄʵÀý£¬¶¼ÓÐ×Ô¼ºµÄÒ»Ì׳ÌÐòÎļþºÍÊý¾ÝÎļþ£¬ÒÔ¼°Ò»Ì×ÔÚ¼ÆËã»úÉϵÄËùÓÐʵÀýÖ®¼ä¹²ÏíµÄ¹«¹²Îļþ¡£
¶ÔÓÚ°üº ......
/*
±ÈÈçExcelÓÐÁ½ÁУ¬AÁкÍBÁÐÐèÒªµ¼Èëµ½SQL±íÖУ¬·´ÕýÎÒÒѾÓм¸Äê²»ÓÃDTSÖ®ÀàµÄ¹¤¾ßÁË¡£
ÔÚExcelÖеÄеÄÒ»ÁÐÖУ¬Ö±½Óд¹«Ê½
=CONCATENATE("Insert #tmp values('",A1,"','",B1,"')")
°ÑÿһÐж¼Éè³ÉͬÑùµÄ¹«Ê½(Ë«»÷¼´¿ÉÍê³É)¡£
°ÑÕûÁи´ÖÆÏÂÀ´£¬·Åµ½²éѯ·ÖÎöÆ÷ÖÐÖ±½ÓÔËÐоͺÃÁË¡£
Ò²¿ÉÒ԰ѹ«Ê½¸Ä³É =CONCATEN ......