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

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 Server »ù´¡

Èí¼þ £º Sql Server 2005
 
    ÕâÀï²¢²»ÊÇSQLÓï·¨´óÈ«£¬ÒÔÏÂÊdz£ÓõÄÓï¾ä£¬¶Ô£¨Êý¾Ý¿â¡¢±í¡¢×ֶΡ¢Êý¾Ý£©µÄÔöɾ¸Ä²é£¬Èç¹ûÐèÒªÏêÏ¸È«ÃæµÄTransact-SQLÓï¾ä£¬¿ÉÒÔ²éSql ServerÁª»ú´ÔÊ飬ÄÇÀïÊÇ×îÈ«µÄ×ÊÁÏ£¬Ò»°ã°²×°Sql Server¶¼»áĬÈϰ²×°¡£
´ò¿ªSql ServerÁª»ú´ÔÊé
¿ªÊ¼ à ³ÌÐò à&n ......

SQL Server2005SQLCLR´úÂ밲ȫ֮ȨÏÞ

Ò»¡¢ SQLCLRȨÏÞ¼¯¼¶±ð
 
¡¡¡¡µ±ÄãʹÓÃCREATE ASSEMBLYÓï¾ä°ÑÒ»¸ö³ÌÐò¼¯¼ÓÔØµ½Ò»¸öÊý¾Ý¿âÖÐʱ£¬SQL ServerÌṩÁËÈýÖÖȨÏÞ¼¯¼¶±ð£ºSAFE£¬EXTERNAL_ACCESSºÍUNSAFE¡£ÕâЩȨÏÞ¼¯ÐγÉÈçͼ3ºÍͼ5£¨¾ùÇë²Î¿¼µÚ¶þƪ£©ËùʾµÄ AppDomain²ßÂÔ¼¶±ð¡£
 
¡¡¡¡ÏÂÃæÊÇÒ»¸öµäÐ͵ÄÓï¾ä£¬ËüʵÏÖ°²×°Î»ÓÚFileLoader.dllÎļþÄÚµ ......

ÔÚSQL Server 2005 ÖÐʹÓÃ.net³ÌÐò¼¯µÄÒ»Ïî×¢Òâ

ÔÚʹÓÃ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 ......

SQLʹÓÃÁ´½Ó·þÎñÆ÷Ö´ÐÐÔ¶³ÌÊý¾Ý¿âÉϵĴ洢¹ý³Ì

 
--´´½¨Á´½Ó·þÎñÆ÷
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.Êý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ