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

¡¾SQL SERVER2005Ò³Ãæ´æ´¢3Ö® ¾Û¼¯Ë÷ÒýµÄ´æ´¢¡¿


                                                       ¾Û¼¯Ë÷ÒýµÄ´æ´¢
 
Ò»£º¾Û¼¯Ë÷ÒýµÄÒ¶¼¶±ð´æ´¢
¾Û¼¯Ë÷ÒýÔÚÒ¶¼¶±ðµÄ´æ´¢Æäʵ¾ÍÊÇÒÔÊý¾ÝÒ³µÄÐÎʽ´æ´¢µÄ,֮ǰ¼¸Æª¹ØÓÚ¶ÑÊý¾ÝÐеĴ洢ÒѾ­¶¼Ïêϸ˵¹ýÁË,µ«ÊÇÕâÀïÒòΪÓÐÁ˾ۼ¯Ë÷Òý,
ËùÒÔ»¹ÊÇÓиöÌØÊâµÄµØ·½ÐèҪעÒâµÄ--´øÓÐΨһ±êʶ·ûµÄ¾Û¼¯Ë÷ÒýÐÐ.
ÎÒÃÇÈç¹ûÔÚ½¨±í²¢ÎªÆ佨Á¢¾Û¼¯Ë÷Òýʱ,ûÓÐΪËüÖ¸¶¨UNIQUEÊôÐÔ,ÄÇôϵͳÔÚ¼üÖµÓöµ½Öظ´µÄʱºò,»á×Ô¶¯Ôö¼ÓÒ»¸ö×Ö½ÚµÄ×Ö¶ÎÀ´±£Ö¤¾Û¼¯¼üÖµµÄΨһ¡£
ÖÁÓÚΪʲôҪ±£Ö¤Ëü¾Û¼¯¼üÖµµÄΨһ,ÄÇôÒòΪ·Ç¾Û¼¯Ë÷ÒýÔÚÒýÓÃËü×÷ΪÊéÇ©µÄʱºò±ØÐëÒªÕ÷ÇóΨһÐÔÀ´È¡µ½Î¨Ò»ÐÐ
/*----------------------------------------------------------------------
*auther:Poofly
*date:2010.3.14
*VERSION:
Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) 
Jul  9 2008 14:43:34 
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 6.1 <X86> (Build 7600: )
*תÔØÇë×¢Ã÷³ö´¦
*¸ü¶à¾«²ÊÄÚÈÝ,Çë½øhttp://blog.csdn.net/feixianxxx
------------------------------------------------------------------------*/
--½¨±í(±íÔ´À´×Ô¼¼ÊõÄÚÄ»)
CREATE TABLE Clustered_Dupes 
  (Col1 char(5)   NOT NULL,
   Col2 int     NOT NULL,
   Col3 char(3)   NULL,
   Col4 char(6)   NOT NULL);
GO
--ÔÚcol1ÉϽ¨²»Î¨Ò»µÄ¾Û¼¯Ë÷Òý
CREATE CLUSTERED INDEX Cl_dupes_col1 ON Clustered_Dupes(col1);
go
--²åÈëÊý¾Ý
INSERT Clustered_Dupes VALUES ('ABCDE', 123, null, 'CCCC');
GO
--ÔËÐÐDBCC


Ïà¹ØÎĵµ£º

SQL Server 2005 CTEµÄÓ÷¨

if object_id('[tb]') is not null
drop table [tb] 
go
create table [tb]([id] int,[col1] varchar(8),[col2] int) 
insert [tb] 
select 1,'ºÓ±±Ê¡',0 union all
 select 2,'ÐĮ̈ÊÐ',1 union all
 select 3,'ʯ¼ÒׯÊÐ',1 union all
 select 4,'ÕżҿÚÊÐ',1 union all
&n ......

ÈçºÎÓÃSQL Óï¾ä¶ÁÈ¡DÅÌÄÚÈÝ

master..xp_dirtree   'D:\',1,1        µÚÒ»¸ö1ÊÇÉî¶È£¬µÚ¶þ¸ö1ÊÇÎļþ
1.   Ö´ÐÐ   master..xp_dirtree   'c:\',1,1,ÕâÑù¿ÉÒÔ»ñÈ¡c:\ϵÄËùÓÐÎļþºÍÎļþ¼Ð,²»°üÀ¨×ÓÎļþ¼Ð¼°Îļþ   
   
2.   ÏÔʾÔÚtreeviewÖÐ,ÓñêÖ ......

SQL×¢È멶´È«½Ó´¥ ½ø½×ƪ

µÚÒ»½Ú¡¢SQL×¢ÈëµÄÒ»°ã²½Öè
Ê×ÏÈ£¬Åжϻ·¾³£¬Ñ°ÕÒ×¢Èëµã£¬ÅжÏÊý¾Ý¿âÀàÐÍ£¬ÕâÔÚÈëÃÅƪÒѾ­½²¹ýÁË¡£
Æä´Î£¬¸ù¾Ý×¢Èë²ÎÊýÀàÐÍ£¬ÔÚÄÔº£ÖÐÖع¹SQLÓï¾äµÄԭò£¬°´²ÎÊýÀàÐÍÖ÷Òª·ÖΪÏÂÃæÈýÖÖ£º
(A) ID=49 ÕâÀà×¢ÈëµÄ²ÎÊýÊÇÊý×ÖÐÍ£¬SQLÓï¾äԭò´óÖÂÈçÏ£º
Select * from ±íÃû where
×Ö¶Î=49
×¢ÈëµÄ²ÎÊýΪID=49 And [²éѯÌõ¼þ ......

sqlÓï¾äµÄÖ´ÐÐ˳ÐòʵÀý½²½â


±ê׼˳ÐòµÄ SQL Óï¾äΪ: 
Select ¿¼ÉúÐÕÃû, max(×ܳɼ¨) as max×ܳɼ¨ 
from tb_Grade 
where ¿¼ÉúÐÕÃû is not null 
group by ¿¼ÉúÐÕÃû 
having max(×ܳɼ¨) > 600 
order by max×ܳɼ¨ 
ÔÚÉÏÃæµÄʾÀýÖÐ SQL Óï¾äµÄÖ´ÐÐ˳ÐòÈçÏÂ: 
(1). Ê×ÏÈÖ´ÐÐ from ×Ó¾ä, ´Ó tb_G ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ