ÔõÑùÓÃSQLÓï¾äÅжÏÒ»¸öÊý¾Ý±íÖÐÖÁÉÙNÏΪ¿Õ£¿£¿£¿
ǰÁ½ÌìÒ»¸öѧ½ãÎÊÎÒ¸öSQLÓï¾äµÄÎÊÌ⣬ÏÖÔڰѽâ¾ö·½°¸Ìù³öÀ´£¬Ò²Ëã×ܽáһϰɡ£
ËýµÄÎÊÌâÊÇ£º“Ò»¸ö±íÖÐÓÐ15¸ö×ֶΣ¬ÓÃSQLÓï¾äÅÐ¶ÏÆäÖÐ5Ïî»òÒÔÉϲ»Îª¿Õ£¬ÔõôÅжϣ¬ºÜ¼±……”¡£
µ±Ê±Î񼆾£¬Ã»¶à¿´£¬ºÇºÇ£¬²»¹»Òâ˼À²¡£µ«ÎÒÇëͬʰïËýдÁ˸ö£¬ÒÔ½âȼü֮¼±£¬ÔÚ´ËҲллСÃס£
½ñÌìÔÙ°ÑQQÁÄÌì¼Ç¼·³öÀ´£¬Óñ¾µØÊý¾Ý¿âÊý¾Ý±íÊÔÑéÁËÏ£¬ ÓеãÎÊÌ⣬ÓÚÊÇ×Ô¼ºÐ޸ġ£
¡¾ÏêϸÇé¿ö£¬Çë²Î¿¼SQL Server Áª»ú´ÔÊé:Ë÷Òý“CASE‘£»
ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.zh-CHS/s10de_6tsql/html/658039ec-8dc2-4251-bc82-30ea23708cee.htm¡¿
¡¾
select distinct (case bulletinId when bulletinId then 1 else 0 end) +
(case title when title then 1 else 0 end) +
(case body when body then 1 else 0 end) +
(case bulletinType when bulletinType then 1 else 0 end) +
(case bulletinState when bulletinState then 1 else 0 end) +
(case companyId when companyId then 1 else 0 end) +
(case userId when userId then 1 else 0 end) +
(case createtime when createtime then 1 else 0 end) as '²»Îª¿Õ×Ö¶ÎÊý' from bulletin
¡¿
µ±Êý¾Ý±íbulletinÖÐÖÁÉÙÓÐÒ»Ìõ¼Ç¼ʱ£¬Ò²¿ÉÒÔ²ÉÈ¡ÏÂÃæµÄ·½·¨¡£
¡¾
1¡¢¼òµ¥ CASE º¯Êý
select * from bulletin where
(case bulletinId when bulletinId then 1 else 0 end) +
(case title when title then 1 else 0 end) +
(case body when body then 1 else 0 end) +
(case bulletinType when bulletinType then 1 else 0 end) +
(case bulletinState when bulletinState then 1 else 0 end) +
(case companyId when companyId then 1 else 0 end) +
(case userId when userId then 1 else 0 end) +
(case createtime when createtime then 1 else 0 end) >= 5
2¡¢CASE ËÑË÷º¯Êý
select * from bulletin where
(case when bulletinId is not null or bulletinId!='' then 1 else 0 end) +
(case when title is not null or title!='' then 1 else 0 end) +
(case when body is not null or body!='' then 1 else 0 end) +
(case when bulletinType is not null or bulletinType!='' then 1 else 0 end) +
(case when bulletinState is not null or bulletinState!='' then 1 else 0 end) +
(case when companyId is not
Ïà¹ØÎĵµ£º
1. Ïû³ýtriggerµÄǶÌ×µ÷Óá£×îºÃ²»ÒªÓà EXEC sp_configure 'nested triggers', '0'£¬ Ó¦¸ÃÔÚtriggerÖÐʹÓÃÅжÏÓï¾ä£¬ ÀýÈ磺if not update (name) return¡£
2. ʹÓà not for replication ½ûÖ¹ÔÚ¸´ÖƵÄʱºò´¥·¢trigger¡£
3. ´´½¨publisher articleµÄʱºò£¬ ÉèÖà copy user triggersΪ true¡£
ÕâÑù±£Ö¤£ºtrigger²»»áǶÌ×µ÷ ......
create or replace procedure c
(
v_deptno in emp.deptno%type,
v_max out emp.sal%type
)
as
begin
select max(sal+nvl(comm,0)) into v_max from emp where deptno=v_deptno;
end;
create or replace procedure cc
(
v_empno in emp.empno%type,
v_sal out emp.sal%type,
v_comm out emp.comm% ......
²éѯËÙ¶ÈÂýµÄÔÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ£º
¡¡¡¡1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿) ......
----start
SQL(Structured Query Language)£¬Ò²¾ÍÊǽṹ»¯²éѯÓïÑÔ£¬Ëü±»Éè¼ÆÓÃÀ´²Ù×÷¼¯ºÏµÄ£¬ÊǷǹý³Ì»¯µÄÓïÑÔ¡£Ëæ×ÅÓ¦ÓóÌÐòµÄ·¢Õ¹£¬ÒµÎñÂß¼Ô½À´Ô½¸´ÔÓ£¬´«Í³µÄSQLÒѾ²»ÄÜÂú×ãÈËÃǵÄÒªÇó£¬ÓÚÊÇÈËÃǶÔSQL½øÐÐÁËÀ©Õ¹£¬Ê¹Ëü¾ßÓÐÁ˹ý³Ì»¯µÄÂß¼£¬¼´£ºSQL PL¡£SQL PLµÄÈ«³ÆÊÇ SQL Procedural Language£ ......
For SQL Server2008:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0e6168b0-2d0c-4076-96c2-60bd25294a8e&displaylang=en
For SQL Server2005:
http://www.microsoft.com/downloads/details.aspx?familyid=C6F14640-DA22-4604-AAAA-A45DE4A0CD4A&displaylang=en ......