SQL¶Ô³ÌÐòÐÔÄܵÄÓ°Ïì
¡¾ÏÈ˼¿¼Ò»¸öÎÊÌ⣺Áû×ÓºÍϹ×ÓÔÚÒ»Æð»áÓÐʲô½á¹û£¿¡¿
×òÌìд³ÌÐò£¬ÓиöСģ¿éÊÇͨ¹ý·ÖÎöÊýÊ®ÍòÌõ¼Ç¼£¬ÓëÒì¹¹µÄÊý¾Ý±í½øÐбȶԣ¬ÕÒ³ö·ûºÏÌõ¼þµÄÐÅÏ¢¡£
ÔÚµÚÒ»Ìõ²éѯÖУ¬ÐèÒª²éѯËùÓмǼµÄÒ»¸ö×ֶΣ¬²¢ÌáÈ¡¸Ã×Ö¶ÎÖеĵÚ5ÖÁµÚ10¸ö×Ö·û´®£¬ÒªÓëÒì¹¹Êý¾Ý±í±È½ÏµÄ¾ÍÊÇÕâ¸ö×Ö´®¡£ÔÚ×î³õµÄ°æ±¾ÖУ¬¶ÔÓÚÐÔÄܲ¢Ã»ÓÐ×ö¸ü¶àµÄ¿¼ÂÇ£¬ÏÈ´ÓÊý¾Ý±íÖлñÈ¡ËùÓеļǼ×é³ÉµÄÊý¾Ý¼¯£¬×÷ΪĿ±êÊý¾Ý£¬ÔÙ´ÓÒì¹¹Êý¾Ý±íÖлñÈ¡Êý¾Ý¼¯×÷Ϊ±È¶ÔÊý¾Ý£¬È»ºóÔÚ³ÌÐòÖо¹ýÖÁÉÙÁ½´Î±éÀú£¬É¸Ñ¡³öÏëÒªµÄ½á¹û¡£ÔÚÕâ¸ö°æ±¾ÖУ¬Ð§Âʺܵ͡£±È¶ÔÊý¾Ý»ù±¾ÉϹ̶¨£¬Ç§°ÑÌõµÄÑù×Ó£¬Ä¿±êÊý¾ÝºÜ¶à£¬¶øÇÒ»áÔ½À´Ô½¶à¡£µ«ÐÔÄܵÄÆ¿¾±²¢²»ÊdzöÏÖÔÚ³ÌÐòÖжà´ÎµÄ±éÀú£¬ÕâЩ¶¼ÔÚÄÚ´æÖнøÐУ¬ÕâµãÊý¾ÝÁ¿ºÍËã·¨£¬¶ÔÓÚÄ¿Ç°µÄ·þÎñÆ÷À´ËµÕæµÄÊÇС²ËÒ»µú¡£¾²âÊÔ£¬ËäȻֻÓм¸Ê®ÍòÐеļǼ£¬²éѯʱ¼äÈ´ÐèÒª5ÃëÒÔÉÏ¡£
ÎÒÔÀ´µÄ˼·ÊÇ£¬ÒòΪµ£ÐÄSQLµÄÐÔÄÜ£¬°Ñ´Ó×Ö¶ÎÖнØÈ¡×Ö·û´®µÄ¼ÆËãÓÉSQLÒÆÖÁ³ÌÐòÖнøÐУ¬µ«Êµ¼ùÖ¤Ã÷£¬¶ÔÓÚ·µ»Ø´óÁ¿¼Ç¼µÄSQL£¬ÆäЧÂÊ·´¶ø¸üµÍÁË¡£ÓÚÊÇ£¬¸Ä±ä˼·£¬»¹ÊÇÀûÓÃSQL½øÐÐɸѡ£¬²¢¾¡Á¿¼õÉÙÊý¾ÝÁ¿£¬ÓÐÁËÀàËÆÏÂÃæÕâÒ»Ðмòµ¥µÄ²éѯ£º
select distinct substring([prodcode],5,10) pcode from [detail] order by pcode
ÔÚÕâ¶Î²éѯÖУ¬Ê×ÏÈÊÇÀûÓÃsubstringº¯Êý£¬ÔÚsqlÖоͷµ»ØÁËÒªÏëµÄ×Ö·û´®£¬×¢ÒâÕâÀïsubstringº¯ÊýºÍC#ÖеÄÇø±ð£¬ËüÊÇ´Ó1¿ªÊ¼Ë÷ÒýµÄ£¬¶øC#ÖÐÔòÊÇ´Ó0¿ªÊ¼£¨ÎÒÔÚ´Ë×ßÁËÍä·£¬Èç¹û´ÏÃ÷µÄÄãÔç¾ÍÖªµÀ£¬ÇëºöÂÔ£©¡£È»ºóÊÇÇ°ÃæÓиö¹Ø¼ü×Ödistinct£¬ÓÃÀ´Ïû³ýÖظ´µÄ¼Ç¼£¨ÕâÀï´æÔÚ´óÁ¿µÄÖظ´Öµ£©¡£Êµ¼ùÖ¤Ã÷£¬ËäÈ»Ôö¼ÓÁËÒ»¸ö½ØÈ¡×Ö·û´®µÄ¼ÆË㣬µ«ÓÉÓÚ·µ»ØµÄ¼Ç¼´ó´ó¼õÉÙ£¬ÕâÖÖÇé¿öÏ£¬Êý¾Ý¿â·þÎñÆ÷·µ»Ø½á¹ûµÄʱ¼äÌáÉýµ½0Ã룬Ҳ¾ÍÊÇ˵ÒѾÊǺÁÃ뼶ÁË£¬SSMS£¨=²éѯ·ÖÎöÆ÷£©¸øºöÂÔÁË¡£
ÖÚËùÖÜÖª£¬I/O¶Ô³ÌÐòÐÔÄܵÄÓ°ÏìÏ൱´ó£¬ÔÚÕâ¸öССµÄʵÀýÖÐÒ²ÄÜ¿´³öÕâÒ»µã¡£×ʼ£¬ÎÒÏ뵱ȻµÄÒÔΪ°Ñ¼ÆËãÒƵ½³ÌÐòÖÐÈ¥×ö£¬¼õÇáÒ»ÏÂÊý¾Ý¿âµÄ¸ºµ££¬Í¬Ê±Ìá¸ßÔËËãЧÂÊ£¬È´ºöÂÔÁËÕâ¸öÎÊÌâ¡£µ±SQL·µ»ØÁË´óÁ¿Êý¾Ý£¬ÕâЩÊý¾ÝÒª´ÓÒ»¸öµØ·½Òƶ¯µ½ÁíÒ»¸öµØ·½£¬´ÓÄ¿Ç°µÄÍøÂçÐÔÄÜÀ´¿´£¬µ¢ÎóµÄʱ¼ä¾ø¶ÔÊDz»¿ÉÒÔºöÂԵġ£
Õâ¸ö¹ÊʸæËßÎÒÃÇ£¬²»ÄÜÏ뵱Ȼ£¬×ö³ÌÐòÈç´Ë£¬×öÈκÎÊÂÇ鶼ÊÇÈç´Ë¡£
PS
£º×îºó²»µÃ²»ÓÖÒª·¢¸öÀÎɧÁË£¬¸Õ²ÅÌá½»µÄʱºò£¬²îµãÓÖ·¢ÉúÇ°¹¦¾¡ÆúµÄʶù£¬ÕýÎÄÎı¾¿òһƬ¿Õ°×£¬ºÍ×òÌìÌáµ½µÄÒ»Ñù¡£Ò²ÐíÊÇÚ¤Ú¤Ö®ÖÐÓÐÉñÁéÔÚ°ïÎÒ£¬ÔÚµãÌá½»°´Å¥Ö®Ç°µÄÄÇһ˲¼ä£¬ÎÒ´òÁ˸öÀäÕ½£¬°ÑÕâÒ»¶ÑÎÄ×Ö¸´ÖƵ½Á˼Çʱ¾
Ïà¹ØÎĵµ£º
from:csdn
ÄÜ·ñÀûÓô¥·¢Æ÷²Ù×÷Ô¶³ÌÊý¾Ý¿â?
------------------------------------------------------------
-----01
------------------------------------------------------------
ÄÜ/********************Á´½ÓÊý¾Ý¿â *******************************/
exec OPENDA ......
ÆäʵÔÚÐÞ¸ÄÊý¾Ý¿âÃû³Æ֮ǰ£¬Èç¹ûÓÐÓû§Á¬½Óµ½Êý¾Ý¿âµÄ»°»áÔì³ÉÊý¾Ý¿âÖØÃüÃûʧ°Ü£¬¿ÉÒÔÏÈÖ´ÐÐ
select spid
from master.dbo.sysprocesses
where dbid=db_id('OldDbName')
½á¹û¼¯ÖÐÏÔʾµÄÊǵ±Ç°Á¬½Óµ½Êý¾Ý¿âOldDbNameµÄÁ¬½Ó
±ÈÈç½á¹ûÊÇ
79
81
µ±È»£¬Êµ¼ÊÖµÓ¦¸Ã²»ÊÇÕâÁ½¸ö
È»ºóÖ´ÐÐ
kill 79
kill 81
¹Ø±ÕÒѽ¨Á¢ ......
1£¬SqlServer´æ´¢¹ý³ÌµÄÊÂÎñ´¦Àí
Ò»ÖֱȽÏͨÓõijö´í´¦ÀíµÄģʽ´ó¸ÅÈçÏ£º
Create procdure prInsertProducts
(
@intProductId int,
@chvProductName varchar(30),
@intProductCount int
)
AS
Declare @intErrorCode int
Select @intErrorCode=@@Error
Begin transaction
if @intError ......
ÔÚÎÒÃǵÄÈÕ³£±à³ÌÖУ¬Êý¾Ý¿âµÄ³ÌÐò»ù±¾É϶¼ÒªÓëSQLÓï¾ä´ò½»µÀ£¬SQLÓï¾äµÄ±àд²»¿É±ÜÃâµÄ³ÉΪһ¸öÍ·Ì۵Ť×÷¡£ÇÒÒòΪSQLÓï¾äÊÇSTRINGÀàÐÍ£¬Òò´ËÔÚ±àÒë½×¶Î²é²»³ö´í£¬Ö»Óе½ÔËÐÐʱ²ÅÄÜ·¢ÏÖ´íÎó¡£
±¾ÎĵĽâ¾ö·½°¸£¬Í¨¹ý×Ô¶¯Éú³ÉSQLÓï¾ä£¬ÔÚÒ»¶¨³Ì¶ÈÉϽµµÍ³ö´íµÄ¸ÅÂÊ£¬´Ó¶øÌá¸ß±à³ÌЧÂÊ¡£ public int ......
--> Title : SQL ServerÖ®·Ö²¼Ê½ÊÂÎñ
--> Author : wufeng4552
--> Date : 2009-11-11
SQL ServerÖ®·Ö²¼Ê½ÊÂÎñ
(Ò»)¸ÅÄî:
·Ö²¼Ê½ÊÂÎñÊÇÉæ¼°À´×ÔÁ½¸ö»ò¶à¸öÔ´µÄ×ÊÔ´µÄÊÂÎñ¡£Microsoft® SQL Server™ 2000Ö§³Ö·Ö²¼Ê½ÊÂÎñ£¬Ê¹Óû§µÃÒÔ´´½¨ÊÂÎñÀ´¸üжà¸öSQL ServerÊý¾Ý¿âºÍÆäËüÊý¾ÝÔ ......