Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sql

ms sql ³£ÓòÙ×÷Óï¾ä

MS SQLµÄһЩ¾­µä³£ÓòÙ×÷Óï¾ä»ã×Ü  ¡¾http://hi.baidu.com/kychen88/blog/item/b3c8e7d960821b3c32fa1cee.html¡¿
1.°´ÐÕÊϱʻ­ÅÅÐò:
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ:
select encrypt('ԭʼÃÜÂë')
select pwdencrypt('ԭʼÃÜÂë')
select pwdcompare('ԭʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ encrypt('ԭʼÃÜÂë')
select pwdencrypt('ԭʼÃÜÂë')
select pwdcompare('ԭʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ
3.È¡»Ø±íÖÐ×Ö¶Î:
declare @list varchar(1000),@sql nvarchar(1000)
select @list=@list+','+b.name from sysobjects a,syscolumns b where a.id=b.id and a.name='±íA'
set @sql='select '+right(@list,len(@list)-1)+' from ±íA'
exec (@sql)
4.²é¿´Ó²ÅÌ·ÖÇø:
EXEC master..xp_fixeddrives
5.±È½ÏA,B±íÊÇ·ñÏàµÈ:
if (select checksum_agg(binary_checksum(*)) from A)
    =
   (select checksum_agg(binary_checksum(*)) from B)
print 'ÏàµÈ'
else
print '²»ÏàµÈ'
6.ɱµôËùÓеÄʼþ̽²ìÆ÷½ø³Ì:
DECLARE hcforeach CURSOR G ......

¼à¿ØSQL Server2005Êý¾Ý¿âµÄÔËÐÐ×´¿ö

Äܼà¿ØSQL ServerÊý¾Ý¿âÔËÐеÄÇé¿ö£¬¶Ô·þÎñÆ÷À´Ëµ¶¼ÊÇÒ»¼þ·Ç³£ÖØÒªµÄÊ£¬ÏÂÃ濪ʼ½éÉÜ¡£
Microsoft SQL Server 2005 ÌṩÁËһЩ¹¤¾ßÀ´¼à¿ØÊý¾Ý¿â¡£·½·¨Ö®Ò»ÊǶ¯Ì¬¹ÜÀíÊÓͼ¡£¶¯Ì¬¹ÜÀíÊÓͼ (DMV) ºÍ¶¯Ì¬¹ÜÀíº¯Êý (DMF) ·µ»ØµÄ·þÎñÆ÷״̬ÐÅÏ¢¿ÉÓÃÓÚ¼à¿Ø·þÎñÆ÷ʵÀýµÄÔËÐÐ×´¿ö¡¢Õï¶ÏÎÊÌâºÍÓÅ»¯ÐÔÄÜ¡£
³£¹æ·þÎñÆ÷¶¯Ì¬¹ÜÀí¶ÔÏó°üÀ¨£º
dm_db_*£ºÊý¾Ý¿âºÍÊý¾Ý¿â¶ÔÏó
dm_exec_*£ºÖ´ÐÐÓû§´úÂëºÍ¹ØÁªµÄÁ¬½Ó
dm_os_*£ºÄÚ´æ¡¢Ëø¶¨ºÍʱ¼ä°²ÅÅ
dm_tran_*£ºÊÂÎñºÍ¸ôÀë
dm_io_*£ºÍøÂçºÍ´ÅÅ̵ÄÊäÈë/Êä³ö
´Ë²¿·Ö½éÉÜΪ¼à¿Ø SQL Server ÔËÐÐ×´¿ö¶øÕë¶ÔÕâЩ¶¯Ì¬¹ÜÀíÊÓͼºÍº¯ÊýÔËÐеÄһЩ³£Óòéѯ¡£
ժ¼²¿·Ö¾«²ÊSQLÈçÏ£º
ÏÂÃæµÄ²éѯÏÔʾ CPU ƽ¾ùÕ¼ÓÃÂÊ×î¸ßµÄÇ° 50 ¸ö SQL Óï¾ä¡£
SELECT TOP 50
total_worker_time/execution_count AS [Avg CPU Time],
(SELECT SUBSTRING(text,statement_start_offset/2,(CASE WHEN statement_end_offset = -1 then LEN(CONVERT(nvarchar(max), text)) * 2 ELSE statement_end_offset end -statement_start_offset)/2) from sys.dm_exec_sql_text(sql_handle)) AS query_text, *
from sys.dm_exec_query_stats
ORDER BY [Avg CPU Time] DESC

Ï ......

pl/sql³£Óú¯Êý

1¡£Sysdate µ±Ç°ÈÕÆÚºÍʱ¼ä
SQL> Select sysdate from dual;
SYSDATE
----------
21-6ÔÂ -05
2¡£Last_day ±¾ÔÂ×îºóÒ»Ìì
SQL> Select last_day(sysdate) from dual;
LAST_DAY(S
----------
30-6ÔÂ -05
3¡£Add_months(d,n) µ±Ç°ÈÕÆÚdºóÍÆn¸öÔÂ
ÓÃÓÚ´ÓÒ»¸öÈÕÆÚÖµÔö¼Ó»ò¼õÉÙһЩÔ·Ý
date_value:=add_months(date_value,number_of_months)
SQL> Select add_months(sysdate,2) from dual;
ADD_MONTHS
----------
21-8ÔÂ -05
4¡£Months_between(f,s) ÈÕÆÚfºÍs¼äÏà²îÔÂÊý
SQL> select months_between(sysdate,to_date('2005-11-12','yyyy-mm-dd'))from dual;
MONTHS_BETWEEN(SYSDATE,TO_DATE('2005-11-12','YYYY-MM-DD'))
----------------------------------------------------------
-4.6966741
5¡£NEXT_DAY(d, day_of_week)
·µ»ØÓÉ"day_of_week"ÃüÃûµÄ£¬ÔÚ±äÁ¿"d"Ö¸¶¨µÄÈÕÆÚÖ®ºóµÄµÚÒ»¸ö¹¤×÷ÈÕµÄÈÕÆÚ¡£²ÎÊý"day_of_week"±ØÐëΪ¸ÃÐÇÆÚÖеÄijһÌì¡£
SQL> SELECT next_day(to_date('20050620','YYYYMMDD'),1) from dual;
NEXT_DAY(T
----------
26-6ÔÂ -05
6¡£current_date()·µ»Øµ±Ç°»á»°Ê±ÇøÖеĵ±Ç°ÈÕÆÚ
date_value:=current_da ......

SQLÓï¾ä£º°Ñͳ¼Æ½á¹û°´ÕÕÌض¨µÄÁÐֵת»»³É¶àÁÐ

ÒªÇ󣺲éѯÿ¸öÀÏʦËù´ø±ÏÒµÉè¼ÆµÄ»ã×ÜÇé¿ö£¬±ÏÒµÉè¼ÆѧÉú·Ö±¾¿Æ¡¢×¨¿Æ£¬ÔºÍâ¡¢ÔºÄÚ£¬ÒªÇóµÃµ½µÄ½á¹ûÐÎʽÈçÏ£º
½ÌʦÃû ÔºÄÚ±¾¿Æ Ô°ÄÚר¿Æ ÔºÍâ±¾¿Æ ÔºÍâר¿Æ ºÏ¼Æ
Ïà¹ØµÄ±íÓУºÑ§Éú±í£¨°üº¬Ñ§Éú²ã´Î£©¡¢½Ìʦ±í£¨½ÌʦÃû£©¡¢Ñ§Éú¿ÎÌâ±í£¨Ñ§Éú½Ìʦ¶ÔÓ¦¹ØϵÒÔ¼°ÔºÄÚÔºÍâÐÅÏ¢£©¡£
SQLÓï¾äÈçÏ£º
select
    teacher.teacher_name,ifnull(c1.c,0) v1,ifnull(c2.c,0) v2,ifnull(c3.c,0) v3,ifnull(c4.c,0) v4,
    (ifnull(c1.c,0)+ifnull(c2.c,0)+ifnull(c3.c,0)+ifnull(c4.c,0)) sum
 from teacher
 left outer join
 (
      select
           teacher_id,count(*) c
      from
           taskbook,student 
      where
            taskbook.taskbook_inner_task='ÔºÄÚ' and degree_id>1 and student.student_id=taskbook.student_id
  ......

ת£º³£ÓÃSQLÓï¾äÊéд¼¼ÇÉ

³£ÓÃSQLÓï¾äÊéд¼¼ÇÉ
×÷Õߣº   À´Ô´£ºjavaeye²©¿Í   ·¢²¼Õߣºadmin
ʱ¼ä£º2009-05-11 10:07:41   µã»÷£º2010
SQL½á¹¹»¯²éѯ×Ö·û´®µÄ¸Äд£¬ÊÇʵÏÖÊý¾Ý¿â²éѯÐÔÄÜÌáÉýµÄ×îÏÖʵ¡¢×îÓÐЧµÄÊֶΣ¬ÓÐʱÉõÖÁÊÇΨһµÄÊֶΣ¬±ÈÈçÔÚ²»ÔÊÐí´ó·ù¶ÈÐÞ¸ÄÏÖÓÐÊý¾Ý¿â½á¹¹µÄÇé¿öÏ¡£
ͨ¹ýÓÅ»¯SQLÓï¾äÌá¸ß²éѯÐÔÄܵĹؼüÊÇ£º
? ¸ù¾Ýʵ¼ÊÐèÇóÇé¿ö£¬½¨Á¢ºÏÊʵÄË÷Òý£»
? ʹÓÃÒ»ÇпÉÄܵķ½Ê½È¥ÀûÓúÃË÷Òý£¬±ÜÃâÈ«±íɨÃ裻
? ¾¡Á¿¼õÉÙÄÚ´æ¼°Êý¾ÝI/O·½ÃæµÄ¿ªÏú
Ò»¡¢ ½¨Á¢Ë÷Òý
£¨Ò»£©½¨Á¢“Êʵ±”µÄË÷Òý£¬ÊÇ¿ìËÙ²éѯµÄ»ù´¡¡£
Ë÷Òý£¨index£©Êdzý±íÖ®ÍâÁíÒ»ÖØÒªµÄ¡¢Óû§¶¨ÒåµÄ´æ´¢ÔÚÎïÀí½éÖÊÉϵÄÊý¾Ý½á¹¹¡£µ±¸ù¾ÝË÷ÒýÂëµÄÖµËÑË÷Êý¾Ýʱ£¬Ë÷ÒýÌṩÁ˶ÔÊý¾ÝµÄ¿ìËÙ·ÃÎÊ¡£ÊÂʵÉÏ£¬Ã»ÓÐË÷Òý£¬Êý¾Ý¿âÒ²Äܸù¾ÝSELECTÓï¾ä³É¹¦µØ¼ìË÷µ½½á¹û£¬µ«Ëæ×űí±äµÃÔ½À´Ô½´ó£¬Ê¹ÓÓÊʵ±”µÄË÷ÒýµÄЧ¹û¾ÍÔ½À´Ô½Ã÷ÏÔ¡£×¢Ò⣬ÔÚÕâ¾ä»°ÖУ¬ÎÒÃÇÓÃÁË“Êʵ±”Õâ¸ö´Ê£¬ÕâÊÇÒòΪ£¬Èç¹ûʹÓÃË÷Òýʱ²»ÈÏÕ濼ÂÇÆäʵÏÖ¹ý³Ì£¬Ë÷Òý¼È¿ÉÒÔÌá¸ßÒ²»áÆÆ»µÊý¾Ý¿âµÄ¹¤×÷ÐÔÄÜ¡£
Ë÷Òýʵ¼ÊÉÏÊÇÒ»ÖÖÌØÊâµÄĿ¼£¬SQL SERVERÌṩÁËÁ½ÖÖË÷Òý£º
? ¾Û¼¯Ë÷Òý£¨clu ......

sql server 2005µÄsaÕ˺ÅÃÜÂëÍü¼ÇÁËÔõô°ì

¾ßÌå½â¾ö²½Öè:
µÚÒ»²½:´ò¿ª SQL2005 ÓùÜÀíÔ±µÇ¼ÏÈ,È»ºóÔÚ·þÎñÃû´¦ÓÒ»÷Ñ¡ÊôÐÔ>°²È«ÐÔ>ÓұߵĵǼ·½Ê½Ñ¡Ïî¸ÄΪ Éí·ÝÑéÖ¤ È·¶¨!
µÚ¶þ²½:Ñ¡Ôñ°²È«ÐÔ(Õ¹¿ª)>µÇ¼Ãû>Ë«»÷sa>ÃÜÂë¸Ä³ÉÄãÐèÒªµÄÃÜÂë È·¶¨!
È»ºó¹ØµôSQL2005 »òÕß ¶Ï¿ªÁ¬½Ó
µÚÈý²½:µã¿ªÊ¼>³ÌÐò>Ñ¡ÔñSQL2005>ÅäÖù¤¾ß>´ò¿ª configuration manager>Õ¹¿ª SQL Server2005 ÍøÂçÅäÖà  
×¢Òâ:Ñ¡ÖÐMSSQLSERVER  Èç¹ûûÓÐ Ñ¡ÖÐSQMEXPRESS
>TCP/IP Ñ¡Ïî >ÏÈÆôÓà ȻºóÓÒ¼üµ¥»÷ > ÊôÐÔ > IpµØÖ·Ñ¡Ï > °ÑÒѽûÓõÄÑ¡ÏîÈ«²¿¸Ä³ÉÒÑÆôÓà > È»ºó°ÑSQL2005 µÄ·þÎñÖØÐÂÆô¶¯Ò»ÏÂ!
ÔÙÓÃsaµÇ¼,¾Í¿ÉÒÔÁË ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [691] [692] [693] [694] 695 [696] [697] [698] [699] [700]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ