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

SQL²éѯÖظ´¼Ç¼

SQL²éѯÖظ´¼Ç¼
http://m.cnblogs.com/15628/1534873.html
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)
[ͼƬ](¶þ)
[ͼƬ]±È·½Ëµ
[ͼƬ]ÔÚA±íÖдæÔÚÒ»¸ö×ֶΓname”£¬
[ͼƬ]¶øÇÒ²»Í¬¼Ç¼֮¼äµÄ“name”ÖµÓпÉÄÜ»áÏàͬ£¬
[ͼƬ]ÏÖÔÚ¾ÍÊÇÐèÒª²éѯ³öÔڸñíÖеĸ÷¼Ç¼֮¼ä£¬“name”Öµ´æÔÚÖظ´µÄÏ
[ͼƬ]Select Name,Count(*) from A Group By Name Having Count(*) > 1
[ͼƬ]Èç¹û»¹²éÐÔ±ðÒ²Ïà


Ïà¹ØÎĵµ£º

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨
Ç°ÑÔ£ºÔÚÊý¾Ý¿â³ÌÐò¿ª·¢µÄ¹ý³ÌÖÐ,ÎÒ勱ÃǾ­³£»áÅöµ½Ñ§Ï°ÀûÓÃEXECÀ´Ö´ÐÐÒ»¶ÎÐèÒª·µ»ØijЩֵµÄsqlÓï¾ä£¨Í¨³£Êǹ¹Ô춯̬sqlÓï¾äʱʹÓã©£¬»òÕßÔÚÒ»¸öHTML´æ´¢¹ý³ÌÖÐÀûÓÃEXECµ÷ÓÃÁíÒ»¸öHTMLÓзµ»ØÖµµÄ´æ´¢¹ý³Ì£¨±ØÐë»ñµÃ·µ»ØÖµ£©£¬ÄÇôÈçºÎ»ñµÃÕâЩ·µ»ØÖµÄØ?
1.EXECÖ´ÐÐsqlÓï¾ ......

¾­µäSQLÓï¾ä´óÈ«

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ëµ ......

¾­µäSQLÓï¾ä´óÈ«

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ëµ ......

ÓÃSQL²éѯ·ÖÎöÆ÷²Ù×÷Excel

ÓÃSQL²éѯ·ÖÎöÆ÷²Ù×÷Excel
http://hi.baidu.com/bilbit/blog/item/adf7a33427af52bed0a2d38e.html
SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö
1¡¢ÔÚSQL SERVERÀï²éѯExcelÊý¾Ý:
-- ======================================================
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\boo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ