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

SQLÊÂÎñ´¦ÀíÓï¾ä×ܽá

 
´æ´¢¹ý³ÌÖг£Óõ½µÄSQLÊÂÎñ´¦ÀíÓï¾ä¸ñʽ¿ÉÄÜ»áÓÐÈçϼ¸ÖÖ:
µÚÒ»ÖÖ:
set   xact_abort   on 
begin   tran 
        insert   ... 
        update   ... 
        delete   ... 
commit   tran
µÚ¶þÖÖ:
set   xact_abort   on 
begin   tran 
        insert   ... 
        if @@error<>0 rollback tran
        update   ... 
        if @@error<>0 rollback tran
        delete   ... 
        if @@error<>0 rollback tran
commit   tran
µÚÈýÖÖ:
set   xact_abort   on 
begin   tran 
        insert   ... 
        update   ... 
        delete   ... 
if @@error<>0 
rollback  tran
else
commit   tran
µÚËÄÖÖ:
set   xact_abort   on 
begin   tran 
declare @ErrorSave int
        insert   ... 
        if @@error<>0  set  @ErrorSave=1
        update   ...  
      if @@error<>0  set  @ErrorSave=1
        delete   ... 
      if @@error<>0  set  @ErrorSave=1
if @ErrorSave>0 
rollback  tran
else
commit   tran
ʹÓÃÊÂÎñµÄȱÏÝ:ʹÓöàÁËÊÂÎñ´¦Àí,¾­³£»á²úÉúËÀËøÏÖÏó,Ìرð


Ïà¹ØÎĵµ£º

MS SQLÊÓͼµÄ×÷ÓÃ

 µÚÒ»µã£º
ʹÓÃÊÓͼ£¬¿ÉÒÔ¶¨ÖÆÓû§Êý¾Ý£¬¾Û½¹Ìض¨µÄÊý¾Ý¡£
½âÊÍ£º
ÔÚʵ¼Ê¹ý³ÌÖУ¬¹«Ë¾Óв»Í¬½ÇÉ«µÄ¹¤×÷ÈËÔ±£¬ÎÒÃÇÒÔÏúÊÛ¹«Ë¾ÎªÀýµÄ»°£¬
²É¹ºÈËÔ±£¬¿ÉÒÔÐèҪһЩÓëÆäÓйصÄÊý¾Ý£¬¶øÓëËûÎ޹صÄÊý¾Ý£¬¶ÔËûû
ÓÐÈκÎÒâÒ壬ÎÒÃÇ¿ÉÒÔ¸ù¾ÝÕâһʵ¼ÊÇé¿ö£¬×¨ÃÅΪ²É¹ºÈËÔ±´´½¨Ò»¸öÊÓ
ͼ£¬ÒÔºóËûÔÚ²éѯÊý¾Ýʱ£¬Ö»Ðèse ......

SQLº¯ÊýSubstringÌáÈ¡²¿·Ö×Ö·û´®

¹¦ÄÜ£º·µ»Ø×Ö·û¡¢¶þ½øÖÆ¡¢Îı¾»òͼÏñ±í´ïʽµÄÒ»²¿·Ö
Óï·¨£ºSUBSTRING ( expression, start, length )
          SQL ÖÐµÄ substring º¯ÊýÊÇÓÃÀ´×¥³öÒ»¸öÀ¸Î»×ÊÁÏÖеÄÆäÖÐÒ»²¿·Ö¡£Õâ¸öº¯ÊýµÄÃû³ÆÔÚ²»Í¬µÄ×ÊÁÏ¿âÖв»ÍêÈ«Ò»Ñù£º
²ÎÊý£º
expression ×Ö·û´®¡¢¶þ½øÖÆ×Ö·û´®¡¢Î ......

oracle±È½Ï¿ìµÄ·ÖÒ³sql

 ·½°¸1 ÊÊÓÃÓÚoracle9iÒÔÉÏ£¡
select * from
(select row_number() over(order by sendid desc) rn,m.* from xxt_msgreceive m )
where rn <1010 and rn>=1000
·½°¸2
SELECT * from (SELECT A.*, ROWNUM RN from (SELECT * from xxt_msg where sendstatus=1  order by msgid desc) A WHERE ROWNUM < ......

OM裡±£Áô記錄備·ÝSQL

 First:
create table gobo.gobo_om_reservations_2008b as
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
commit
After 2009Year:
create table gobo.gobo_om_reservations_????b as ......

sql ¼òµ¥Óαê

 ÔÚ´æ´¢¹ý³Ì»ò´¥·¢Æ÷ÖÐʹÓà Transact-SQL ÓαêµÄµäÐ͹ý³ÌΪ£º
ÉùÃ÷ Transact-SQL ±äÁ¿°üº¬Óα귵»ØµÄÊý¾Ý¡£ÎªÃ¿¸ö½á¹û¼¯ÁÐÉùÃ÷Ò»¸ö±äÁ¿¡£ÉùÃ÷×ã¹»´óµÄ±äÁ¿À´±£´æÁзµ»ØµÄÖµ£¬²¢ÉùÃ÷±äÁ¿µÄÀàÐÍΪ¿É´ÓÁÐÊý¾ÝÀàÐÍÒþʽת»»µÃµ½µÄÊý¾ÝÀàÐÍ¡£
ʹÓà DECLARE CURSOR Óï¾ä½« Transact-SQL ÓαêÓë SELECT Óï¾äÏà¹ØÁª¡£ÁíÍ⣬D ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ