Sql»ù±¾Óï¾äµÄѧϰ
--²éѯÿ¸öÈ˶©·¹µÄ´ÎÊý
select username as ÐÕÃû, count(*) as ´ÎÊý from orderitems group by UserName having count(*)=1
order by ÐÕÃû desc
select distinct username as δע²áÐÕÃû from orderitems
where username not in (select [Name] from Person)
select distinct username as ÒÑ×¢²áÐÕÃû from orderitems where username
in (select [Name] from Person)
--Ë÷ÒýΪ31-40µÄÊý¾Ý
select top 10 * from orderitems where ID not in (select top 30 ID from orderitems)
--¸´ÖÆÊý¾Ý
insert into distinctselect(UserName,State,OrderTime) select UserName,State,OrderTime from orderitems
--È¥³ýËùÓÐÖØ¸´µÄ¼Ç¼(ÍêÈ«ÖØ¸´)
select distinct UserName ,ID, State,OrderTime into #Table1 from [distinctselect]
delete from [distinctselect]
insert into [distinctselect](UserName,State,OrderTime) select UserName,State,OrderTime from #Table1
drop table #Table1
--ɾ³ýijÁÐÖØ¸´µÄ¼Ç¼
delete t
from [distinctselect] t
where exists (
select 1 from [distinctselect] where username=t.username and id<t.id)
select * from [distinctselect] order by username
delete from [distinctselect]
Ïà¹ØÎĵµ£º
ÎÒÏëÃæÊÔ¹ýÈí¼þ¿ª·¢µÄÅóÓѶ¼»áÅöµ½sql·½ÃæµÄÃæÊÔÌ⣬Õâ¸ö¿ÉÒÔ˵ÊÇÃæÊԱؿ¼µÄ¡£ÕâÀïÄü¸¸öÀý×Ó¿ªÍØÒ»ÏÂ˼·¡£
1.
ÓÐÕâÑùÒ»Õűí
½ÌʦºÅ
ÐÇÆÚ
ÊÇ·ñÓпÎ
1
1
ÓÐ
2
3
ÓÐ
1
2
ÓÐ
1
2
ÓÐ
ÒªµÃ³öÕâÑùµÄÊý¾Ý£º
ÐÕÃû
ÐÇÆÚÒ»
ÐÇÆÚ¶þ
ÐÇÆÚÈý
ÐÇÆÚËÄ
ÐÇÆÚÎå
1
1
......
Ó¦ÓÃIDS·ÀÖ¹SQL×¢Èë¹¥»÷
http://www.cnhacker.com/Hacker/Skills/200807/t20080731_6187.html
Ŀǰ£¬Õë¶ÔÓ¦Óü°Æäºǫ́Êý¾Ý¿âµÄÓ¦Óü¶ÈëÇÖÒѾ±äµÃÔ½À´Ô½²þâ±£¬ÈçSQL×¢Èë¡¢¿çÕ¾µã½Å±¾¹¥»÷ºÍδ¾ÊÚȨµÄÓû§·ÃÎʵȡ£ËùÓÐÕâЩÈëÇÖ¶¼ÓпÉÄÜÈÆ¹ýǰ̨°²È«ÏµÍ³²¢¶ÔÊý¾ÝÀ´Ô´·¢Æð¹¥»÷¡£
ΪÁ˶Ը¶ÕâÀàÍþв£¬ÐÂÒ»¼¶±ðµÄ°²È«ÍÑÓ±¶ø³ö£ ......
ÔÚʹÓÃCLR´æ´¢¹ý³ÌÖÐÓöµ½µÄһЩÎÊÌ⣬ÔÚÕâÀï½øÐмǼ£º
´ò¿ªCLRµÄÖ§³Ö
--ÔÚSql ServerÖÐÖ´ÐÐÕâ¶Î´úÂë¿ÉÒÔ¿ªÆôCLR
exec sp_configure 'show advanced options', '1';
go
reconfigure;
go
exec sp_configure 'clr enabled', '1'
go
reconfigure;
exec sp_c ......
--´´½¨Á´½Ó·þÎñÆ÷
exec sp_addlinkedserver 'server_tmp','','SQLOLEDB','Ô¶³Ì·þÎñÆ÷Ãû»òipµØÖ·'
exec sp_addlinkedsrvlogin 'server_tmp','false',null,'Óû§Ãû','ÃÜÂë'
exec sp_serveroption 'server_lnk','rpc out','true' --Õâ¸öÔÊÐíµ÷ÓÃÁ´½Ó·þÎñÆ÷ÉϵĴ洢¹ý³Ì
go
--µ÷Óãº
exec server_tmp.Êý¾ ......
Oracleµ÷ÕûÓëSQL Óï¾äµÄµ÷ÓŵĹØÏµ
ÔÚOracleµ÷ÕûÖÐÎÒÃÇ»¹»áÉæ¼°µ½SQL Óï¾äµÄµ÷ÓÅ£¬ÎÒÃǽÓÏÂÀ´¾ÍÀ´¿´ÒÔÏ嵀 SQL Óï¾äµÄµ÷ÓÅ¡£ÎÒÃǶ¼ÖªµÀ Oracle ÖÐµÄ SQL µ÷ÓÅÊÇÒ»¸öÏ൱¸´ÔÓµÄÖ÷Ì⣬ÉõÖÁÊÇÐèÒªÕû±¾ÊéÀ´½éÉÜ Oracle SQL µ÷ÓŵÄϸ΢²î±ð¡£
²»¹ýÓÐһЩ»ù±¾µÄ¹æÔòÊÇÿ¸ö Oracle DBA ¶¼ÐèÒª¸ú´ÓµÄ£¬ÕâЩ¹æÔò¿ÉÒÔ¸ÄÉÆËûÃÇϵͳµÄ ......