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
Ïà¹ØÎĵµ£º
C#¡¢ASP.NETÖн«Excel±íÖеÄÊý¾Ýµ¼Èëµ½Sql ServerÊý¾Ý¿âÖжÔÓ¦µÄ±íÖС£
ÕâÀïÎÒÃǽ«E:\test.xls
ÖÐSheet1
±íÖеÄÊý¾Ýµ¼Èëµ½testÊý¾Ý¿âÖеÄmy_test
±íÖС£
Èí¼þ£ºVS2005£¬SQL Server2000,
test.xlsÖÐSheet1±íÖÐÓÐÈý¸ö×ֶΣ¬±àºÅ¡¢Ãû³Æ¡¢±¸×¢¡£¾ßÌåÄÚÈÝÈçÏÂͼ¡£
1¡¢
Ê×ÏÈ£¬ÎÒÃÇÒ ......
ÏÂÃæÊÇÎÒ×ܽá³öÀ´µÄÒ»¸öÊý¾Ý¿â·ÃÎʹ«¹²À࣬»ùÓÚADO.NET£¬C#µÄ£¬ÆäÖУ¬ÒÔÖØÔصķ½Ê½ÊµÏÖʹÓôæÊô¹ý³ÌµÄ½Ó¿ÚºÍ²»Óô洢¹ý³ÌµÄ½Ó¿Ú£¬ÈçÓв»Í×Çë´ó¼ÒÖ¸Õý£¬Ð»Ð»~
×÷Õߣºshinehoo
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace shineh ......
ÎÊÌâÌá³ö:
ÔÚÓ¦ÓóÌÐòÖо³£ÐèÒª²éѯÊý¾Ý¡£µ±²éѯ½á¹ûÊý¾ÝÁ¿±È½Ï´óµÄʱºò£¬¼ìË÷½á¹û¡¢½çÃæÏÔʾ¶¼ÐèÒª»¨·Ñ´óÁ¿µÄʱ¼ä¡£ÎªÁ˱ÜÃâÕâ¸öÎÊÌ⣬Ӧ¸Ãÿ´ÎÖ»¼ìË÷²¿·ÖÊý¾Ý£¬Ò²¾ÍÊÇʹÓó£¼ûµÄ·ÖÒ³·½Ê½À´´¦Àí¡£·ÖÒ³µÄÎÊÌâÔÚasp.netÖкÃÏñ·Ç³£¼òµ¥£¬Ö»ÒªÔÚGridViewÖÐÆôÓ÷ÖÒ³¾Í¿ÉÒÔÁË¡£ÆôÓ÷ÖÒ³ºó£¬GridView¹ØÁªÊý¾ÝÔ´¿Ø¼þ£¬ÒÀ¾É»á¼ÓÔØ ......
±¾À´ÊÇmssql+hibernate+native SQL Ó¦ÓõĺܺÍг
µ«Êǵ½ÁË°Ñmssql»»³Émysql£¬¾Í³öÁË´í(ͬÑùµÄÊý¾Ý½á¹¹ºÍÊý¾Ý)¡£
²éѯ·½·¨ÊÇ£º
String sql =
"select id XXX_ID from t_tab";
List<Map> list = session.createSQLQuery(sql)
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
.list();
´í ......