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

SQL SERVERÈçºÎ¼õÉÙËÀËø

 Ö÷ÒªÕë¶ÔSQL ServerÊý¾Ý¿âËÀËøÏÖÏóµÄÔ¤·À¼°½â¾ö´ëÊ©½øÐÐÁËÏêϸµÄ½éÉÜ£¬¸ü¶àÄÚÈÝÇë´ó¼Ò²Î¿¼ÏÂÎÄ£º
¡¡¡¡ËÀËøÊÇÖ¸ÔÚij×é×ÊÔ´ÖУ¬Á½¸ö»òÁ½¸öÒÔÉϵÄÏß³ÌÔÚÖ´Ðйý³ÌÖУ¬ÔÚÕù¶áijһ×ÊԴʱ¶øÔì³É»¥ÏàµÈ´ýµÄÏÖÏó£¬ÈôÎÞÍâÁ¦µÄ×÷ÓÃÏÂ,ËüÃǶ¼½«ÎÞ·¨ÍƽøÏÂÈ¥£¬ËÀʱ¾Í¿ÉÄÜ»á²úÉúËÀËø,ÕâЩÓÀÔ¶ÔÚ»¥ÏàµÈ´ýµÄ½ø³Ì³ÆΪËÀËøÏ̡߳£¼òµ¥µÄ˵£¬½ø³ÌAµÈ´ý½ø³ÌBÊÍ·ÅËûµÄ×ÊÔ´£¬BÓֵȴýAÊÍ·ÅËûµÄ×ÊÔ´£¬ÕâÑù»¥ÏàµÈ´ý¾ÍÐγÉËÀËø¡£
¡¡¡¡ÈçÔÚÊý¾Ý¿âÖУ¬Èç¹ûÐèÒª¶ÔÒ»ÌõÊý¾Ý½øÐÐÐ޸ģ¬Ê×ÏÈÊý¾Ý¿â¹ÜÀíϵͳ»áÔÚÉÏÃæ¼ÓËø£¬ÒÔ±£Ö¤ÔÚͬһʱ¼äÖ»ÓÐÒ»¸öÊÂÎñÄܽøÐÐÐ޸IJÙ×÷¡£ÈçÊÂÎñ1µÄÏß³Ì T1¾ßÓбíAÉϵÄÅÅËüËø£¬ÊÂÎñ2µÄÏß³ÌT2 ¾ßÓбíBÉϵÄÅÅËüËø£¬²¢ÇÒÖ®ºóÐèÒª±íAÉϵÄËø¡£ÊÂÎñ2ÎÞ·¨»ñµÃÕâÒ»Ëø£¬ÒòΪÊÂÎñ1ÒÑÓµÓÐËü¡£ÊÂÎñ2±»×èÈû£¬µÈ´ýÊÂÎñ1¡£È»ºó£¬ÊÂÎñ1ÐèÒª±íBµÄËø£¬µ«ÎÞ·¨»ñµÃËø£¬ÒòΪÊÂÎñ2½«ËüËø¶¨ÁË¡£ÊÂÎñÔÚÌá½»»ò»Ø¹ö֮ǰ²»ÄÜÊͷųÖÓеÄËø¡£ÒòΪÊÂÎñÐèÒª¶Ô·½¿ØÖƵÄËø²ÅÄܼÌÐø²Ù×÷£¬ËùÒÔËüÃDz»ÄÜÌá½»»ò»Ø¹ö£¬ÕâÑùÊý¾Ý¿â¾Í»á·¢ÉúËÀËøÁË¡£
¡¡¡¡ÈçÔÚ±àд´æ´¢¹ý³ÌµÄʱºò£¬ÓÉÓÚÓÐЩ´æ´¢¹ý³ÌÊÂÎñÐԵIJÙ×÷±È½ÏƵ·±£¬Èç¹ûÏÈËøס±íA£¬ÔÙËøס±íB£¬ÄÇôÔÚËùÓеĴ洢¹ý³ÌÖж¼Òª°´ÕÕÕâ¸ö˳ÐòÀ´Ëø¶¨ËüÃÇ¡£Èç¹ûÎÞÒâÖÐij¸ö´æ´¢¹ý³ÌÖÐÏÈËø¶¨±íB£¬ÔÙËø¶¨±íA£¬Õâ¿ÉÄܾͻᵼÖÂÒ»¸öËÀËø¡£¶øÇÒËÀËøÒ»°ãÊDz»Ì«ÈÝÒ×±»·¢Ïֵġ£
¡¡¡¡Èç¹û·þÎñÆ÷ÉϾ­³£³öÏÖÕâÖÖËÀËøÇé¿ö£¬¾Í»á½µµÍ·þÎñÆ÷µÄÐÔÄÜ£¬ËùÒÔÓ¦ÓóÌÐòÔÚʹÓõÄʱºò£¬ÎÒÃǾÍÐèÒª¶ÔÆä½øÐиú×Ù£¬Ê¹ÓÃsp_whoºÍsp_who2À´È·¶¨¿ÉÄÜÊÇÄÄЩÓû§×èÈûÁËÆäËûÓû§£¬ÎÒÃÇ»¹¿ÉÒÔÓÃÏÂÃæµÄ´æ´¢¹ý³ÌÀ´¸ú×Ù¾ßÌåµÄËÀËøÖ´ÐеÄÓ°Ï죺
¡¡¡¡
¡¡¡¡create procedure sp_who_lock
¡¡¡¡as
¡¡¡¡begin
¡¡¡¡declare @spid int,@bl int,
¡¡¡¡@intTransactionCountOnEntry int,
¡¡¡¡@intRowcount int,
¡¡¡¡@intCountProperties int,
¡¡¡¡@intCounter int
¡¡¡¡create table #tmp_lock_who (id int identity(1,1),spid smallint,bl smallint)
¡¡¡¡IF @@ERROR<>0 RETURN @@ERROR
¡¡¡¡insert into #tmp_lock_who(spid,bl) select 0 ,blocked
¡¡¡¡ from (select * from sysprocesses where blocked>0 ) a
¡¡¡¡ where not exists(select * from (select * from sysprocesses where blocked>0 ) b
¡¡¡¡ where a.blocked=spid)
¡¡¡¡ union select spid,blocked from sysprocesses where blocked>0
¡¡¡¡IF @@ERROR<>0 RETURN @@ERROR
¡¡¡¡
¡¡¡¡


Ïà¹ØÎĵµ£º

SQLÁ¬½Ó·ÖÀ༰ʹÓÃ˵Ã÷

 Í¨¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......

SQLÖеÄDDL,DML,DCLÓïÑÔ

     ¸Ð¾õ×Ô¼ºÊDZȽϱ¿µÄ£¬Ñ§Ï°¹ýSQLÓïÑÔ£¬µ«ÊÇÈ´·Ö²»Ì«Çå³þDDL¡¢DML¡¢DCLÓïÑÔ£¬ËùÒÔÄØ£¬½ñÌì¾Íºñ×ÅÁ³Æ¤ÎÊÁËÀÏʦ£¬ÏÖÔÚ¾Í×Ô¼ºÄ¿Ç°µÄÁ˽âÀ´×ܽáһϡ£
1¡¢DDL£¨DATA DEFINITION LANGUAGE£©Êý¾ÝÃèÊöÓïÑÔ
     DDLÓï¾ä²»»á²úÉú»¹Ô­Êý¾Ý£¬ËùÒÔɾ³ýµÄÊý¾ÝÒ²ÊÇÎÞ·¨»Ö¸´µÄ
CREATE - to ......

¹ÜÀí SQL Server µÄÊÂÎñÈÕÖ¾

ÎÄÕÂÀ´Ô´£ºHttp://www.simple-talk.com
Ô­ÎĵØÖ·£ºhttp://www.simple-talk.com/sql/learn-sql-server/managing-transaction-logs-in-sql-server/
Ô­×÷ÕߣºRobert Sheldon
·­Ò룺Èý½úÒ»Ö¦»¨
ÒëÎÄÔ­µØÖ·£ºhttp://prj.souty.cn/Admin/Knowledges/ShowKnowledge.aspx?id=44dbde74-d2c5-41a5-a8e9-375ba7103025
ÔÚ SQL Serv ......

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

 ×ª×Ô£ºhttp://jianghaifeng.blogchina.com/3841741.html
 SQL½á¹¹»¯²éѯ×Ö·û´®µÄ¸Äд£¬ÊÇʵÏÖÊý¾Ý¿â²éѯÐÔÄÜÌáÉýµÄ×îÏÖʵ¡¢×îÓÐЧµÄÊֶΣ¬ÓÐʱÉõÖÁÊÇΨһµÄÊֶΣ¬±ÈÈçÔÚ²»ÔÊÐí´ó·ù¶ÈÐÞ¸ÄÏÖÓÐÊý¾Ý¿â½á¹¹µÄÇé¿öÏ¡£
ͨ¹ýÓÅ»¯SQLÓï¾äÌá¸ß²éѯÐÔÄܵĹؼüÊÇ£º
 ¸ù¾Ýʵ¼ÊÐèÇóÇé¿ö£¬½¨Á¢ºÏÊʵÄË÷Òý£»
&# ......

SQL£ºÈçºÎ°Ñ¶àÐвéѯ½á¹û£¬×÷ΪһÐзµ»Ø

CREATE    FUNCTION dbo.UF_GetInvoiceSerials( @bizCode VARCHAR(10))
   RETURNS VARCHAR(100)
AS
BEGIN
   DECLARE @ret AS VARCHAR(1000)
   SELECT @ret=Coalesce(@ret + ', ','') +
         CASE e.ID
     ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ