SQLÊý¾Ý¿â±í»µÁ˵ÄÊÖ¶¯»Ö¸´·½·¨
½ñÌì½Óµ½¿Í»§µç»°£¬Ëµ²Ù×÷Êý¾ÝÎÞ·¨±£´æ¡£¾¹ý·ÖÎö£¬·¢ÏÖËûµÄÊý¾Ý¿âÒѾÓÐ5G¶àµÄ´óС£¬¶ø×îÖÕ·¢ÏÖÓÐÕűíµÄË÷Òý³ö´íÁË£¬ÓÃDBCC CHECKÒ²ÎÞÁ¦»ØÌì¡£
ÿ´ÎÓÃselect * from ln003082 Óï¾ä²éѯ£¬¶¼±¨ÈçÏ´íÎó£º
·þÎñÆ÷: ÏûÏ¢ 605£¬¼¶±ð 21£¬×´Ì¬ 1£¬ÐÐ 1
ÊÔͼ´ÓÊý¾Ý¿â 'ln_fl0125' ÖÐÌáÈ¡µÄÂß¼Ò³ (1:629904) ÊôÓÚ¶ÔÏó '869578136'£¬¶ø·Ç¶ÔÏó 'LN003082'¡£
Á¬½ÓÖжÏ
û°ì·¨£¬Ö»ÄÜÏë°ì·¨»Ö¸´ÁË¡£»¹ºÃÓм¸Î»ÀÏÊÖÔÚÉí±ß¡£ÓÚÊÇͨÈçÒÔϲ½ÖèÃãÇ¿»Ö¸´ÓÐЧÊý¾Ý£¬µ±È»£¬Óв¿·Ýµ¥×ÓÊý¾ÝÊǶªÊ§ÁË¡£Ö»Äܽпͻ§ÔÙÈ¥²¹ÁË¡£
Ê×ÏÈҪȷ¶¨ÄÄЩÊý¾Ý»Ø²»À´ÁË£¬Í¨¹ýÓαêÀ´Ò»Ò»È·¶¨ÄÄЩÊý¾ÝÎÞЧÁË¡£
declare @bill_no varchar(20)
declare @shop_no varchar(20)
DECLARE @QTY INT
DECLARE terminal_changecursor CURSOR FOR
select bill_no,shop_no from terminal_change
group by shop_no,bill_no
ORDER by shop_no,bill_no
OPEN terminal_changecursor
FETCH NEXT from terminal_changecursor into @bill_no ,@shop_no
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT from terminal_changecursor into @bill_no ,@shop_no
PRINT @bill_no +'-'+@shop_no
IF NOT (
(@bill_no='MB10010033' AND @shop_no = 'P9ZT') OR
(@bill_no='MT90910001' AND @shop_no = 'P9ZT') OR
(@bill_no='MT00110002' AND @shop_no = 'P10D') OR
(@bill_no='MB10010034' AND @shop_no = 'P9ZT') OR
(@bill_no='MB10010035' AND @shop_no = 'P9ZT')
)
select @QTY=sum(bill_qty) from LN003082 WHERE bill_no=@bill_no AND shop_no=@shop_no
ENDEND
DEALLOCATE terminal_changecursor
GO
ͨ¹ýÉÏÃæµÄÓï¾ä£¬¿ÉÒԲ鵽ÄÄЩµ¥ºÅµÄÊý¾Ý³öÁËÎÊÌâ¡£ÓÃIFÌø¹ýÓÐÎÊÌâµÄÊý¾Ý£¬µ±select sumͨ¹ýÓαê²éѯʱ£¬Èç¹ûÓÐÎÊÌâµÄÊý¾Ý£¬¾Í»áÍ£ÏÂÀ´Öжϣ¬¸ù¾Ýprint³öÀ´µÄµ¥ºÅ£¬½«Æä¼ÓÈëÏ´ÎIFÖУ¬Õâ¸ö²½ÖèºÜ¿ÝÔï¡£²»¹ýÒ»°ã²»»á³öÏÖ¹ý¶à¶ªÊ§µÄÊý¾Ý£¬Ò²Ö»ÄÜÕâÑùһһȷ¶¨ÁË¡£
½ÓÏÂÀ´¾ÍÊǸù¾Ý²éѯ³öÀ´ÓÐÎÊÌâµÄÊý¾Ý£¬½øÐйýÂ˻ָ´ÁË¡£
»Ö¸´·½·¨½Å±¾ÈçÏ£º
Ö÷ÒªÓÐ3²½¡£
--˵Ã÷£ºÖն˱䶯Êý¾Ý±í»µÁË£¬¶ªÊ§ÎåÕÅÊý¾Ý£¬ÇëÍ¨ÖªÖØ´«
--1¡£Öؽ¨±íLN003082ΪLN003082_new,ÓÃÓÚ×ªÒÆÓÐЧÊý¾Ý
select * into LN003082_ne
Ïà¹ØÎĵµ£º
ÎÒÃÇÕâÀï¶Ô SQL Server ×Ö·û´®º¯Êý½øÐзÖÃűðÀàµØÁгö£¬±ãÓÚ²éÔĺͼÇÒ䣬ÏàÐÅ´ó¼Ò¶¼ÔÚÆäËü·½ÃæÓиßÉîµÄ±à³Ì»ù´¡£¬´Ó×ÖÃæÉÏÀ´Ëµ´ó¼Ò¶¼ÖªµÀÕâЩº¯ÊýµÄÒâÒ壬¾Í²»¶ÔÕâЩº¯Êý×÷¹ý¶àµÄ½âÊÍÁË£¬Ö÷Ҫ̸Щ¾Ñ飬¾ßÌåÇë²Î¼ûÁª»ú´ÔÊé¡£
ASCII(character_expression) ·µ»Ø×î×ó¶Ë×Ö·ûµÄ ASCII ´úÂëÖµ
CHAR(integer_expression)
UNICO ......
---È·ÈÏ·ÖÅäÆ¿¾±
SELECT session_id,wait_duration_ms,resource_description
from sys.dm_os_waiting_tasks
WHERE wait_type LIKE 'PAGE%LATCH_%' AND
resource_description LIKE '2:%'
--²éѯtempdbÖе±Ç°Òý·¢×î¶à·ÖÅäºÍ»ØÊÕ²Ù×÷
SELECT TOP 10
t1.session_id
,t1. ......
ÆäʵÄã¿ÉÒÔʹÓÃÊÂÎñ´¦Àí
±È·½ËµÔÚÒ»¸ö×Ö¶ÎÀïÃæÌí¼ÓÒ»¸öboolean µÄ×ֶε±ÄãÒª´¦Àí¸Ã×ֶεÄʱºò¾Í True ÄÄô±ðµÄÈ˶¼²»¿ÉÒÔ½øÐвÙ×÷
¡¡Èç¹ûÊÇFalse ÄÄô¾Í¿ÉÒÔ½øÐвÙ×÷¡«¡«ºÇ¿É¡«¡«ÎÒÊÇÕâÑùµÄ
¡¡¡¡²»¹ýÄã¿ÉÒÔ¿´¿´¡¡
¡¡SQLËø»úÖÆ
¡¡¡¡ÒÔÏÂÊÇÎÒÕÒµÄһЩÁÏ¡¡Èç¹ûÒªÀí½âSQLËø»úÖÆ ×îºÃ°ÑÏÂÀ´¿´ÍêŶ
ĬÈϵÄÊÂÎñ¸ôÀë¼ ......
ÏÂÃæÊÇÎÒ×ܽá³öÀ´µÄÒ»¸öÊý¾Ý¿â·ÃÎʹ«¹²À࣬»ùÓÚADO.NET£¬C#µÄ£¬ÆäÖУ¬ÒÔÖØÔØµÄ·½Ê½ÊµÏÖʹÓôæÊô¹ý³ÌµÄ½Ó¿ÚºÍ²»Óô洢¹ý³ÌµÄ½Ó¿Ú£¬ÈçÓв»Í×Çë´ó¼ÒÖ¸Õý£¬Ð»Ð»~
×÷Õߣºshinehoo
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace shineh ......
ÔÚʹÓÃSQL ServerÊý¾Ý¿âʱ, Èç¹ûÐèÒª·ÃÎÊÔ¶³ÌµÄÁíÍâÒ»¸öÊý¾Ý¿â, ÄÇô¿ÉÒÔʹÓÃLinked ServerÀ´ÊµÏÖÕâ¸ö¹¦ÄÜ, ºÜ·½±ã. ±¾ÎÄ×ܽáÁË×Ô¼ºÔÚʹÓÃLinked Server¹¦ÄÜʱÓöµ½µÄ¼¸¸öÎÊÌâ, Èç¹ûÉÔ²»×¢Òâ,ºÜ¿ÉÄܳöÏÖ¸÷ÖÖ´íÎó.
1)´´½¨ÁËÒ»¸öеÄLinked Serverºó, ÐèÒªÊ×ÏÈÉèÖÃlogin ÕË»§, ÓÒ¼ü->ÊôÐÔ->Security, Èçͼ
......