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

SQL Ñ­»·

declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
---------------
while Ìõ¼þ
begin
Ö´ÐвÙ×÷
set @i=@i+1
end
WHILE
ÉèÖÃÖظ´Ö´ÐÐ SQL Óï¾ä»òÓï¾ä¿éµÄÌõ¼þ¡£Ö»ÒªÖ¸¶¨µÄÌõ¼þΪÕ棬¾ÍÖظ´Ö´ÐÐÓï¾ä¡£¿ÉÒÔʹÓà BREAK ºÍ CONTINUE ¹Ø¼ü×ÖÔÚÑ­»·ÄÚ²¿¿ØÖÆ WHILE Ñ­»·ÖÐÓï¾äµÄÖ´ÐС£
Óï·¨
WHILE Boolean_expression
     { sql_statement | statement_block }
     [ BREAK ]
     { sql_statement | statement_block }
     [ CONTINUE ]
²ÎÊý
Boolean_expression
·µ»Ø TRUE »ò FALSE µÄ±í´ïʽ¡£Èç¹û²¼¶û±í´ïʽÖк¬ÓÐ SELECT Óï¾ä£¬±ØÐëÓÃÔ²À¨ºÅ½« SELECT Óï¾äÀ¨ÆðÀ´¡£
{sql_statement | statement_block}
Transact-SQL Óï¾ä»òÓÃÓï¾ä¿é¶¨ÒåµÄÓï¾ä·Ö×é¡£ÈôÒª¶¨ÒåÓï¾ä¿é£¬ÇëʹÓÿØÖÆÁ÷¹Ø¼ü×Ö BEGIN ºÍ END¡£
BREAK
µ¼Ö´Ó×îÄÚ²ãµÄ WHILE Ñ­»·ÖÐÍ˳ö¡£½«Ö´ÐгöÏÖÔÚ END ¹Ø¼ü×ÖºóÃæµÄÈκÎÓï¾ä£¬END ¹Ø¼ü×ÖΪѭ»·½áÊø±ê¼Ç¡£
CONTINUE
ʹ WHILE Ñ­»·ÖØпªÊ¼Ö´ÐУ¬ºöÂÔ CONTINUE ¹Ø¼ü×ÖºóµÄÈκÎÓï¾ä¡£
×¢ÊÍ
Èç¹ûǶÌ×ÁËÁ½¸ö»ò¶à¸ö WHILE Ñ­»·£¬ÄÚ²ãµÄ BREAK ½«µ¼ÖÂÍ˳öµ½ÏÂÒ»¸öÍâ²ãÑ­»·¡£Ê×ÏÈÔËÐÐÄÚ²ãÑ­»·½áÊøÖ®ºóµÄËùÓÐÓï¾ä£¬È»ºóÏÂÒ»¸öÍâ²ãÑ­»·ÖØпªÊ¼Ö´ÐС£
ʾÀý
A. ÔÚǶÌ×µÄ IF...ELSE ºÍ WHILE ÖÐʹÓà BREAK ºÍ CONTINUE
ÔÚÏÂÀýÖУ¬Èç¹ûƽ¾ù¼Û¸ñÉÙÓÚ $30£¬WHILE Ñ­»·¾Í½«¼Û¸ñ¼Ó±¶£¬È»ºóÑ¡Ôñ×î¸ß¼Û¡£Èç¹û×î¸ß¼ÛÉÙÓÚ»òµÈÓÚ $50£¬WHILE Ñ­»·ÖØÐÂÆô¶¯²¢Ôٴν«¼Û¸ñ¼Ó±¶¡£¸ÃÑ­»·²»¶ÏµØ½«¼Û¸ñ¼Ó±¶Ö±µ½×î¸ß¼Û¸ñ³¬¹ý $50£¬È»ºóÍ˳ö WHILE Ñ­»·²¢´òÓ¡Ò»ÌõÏûÏ¢¡£
USE pubs
GO
WHILE (SELECT AVG(price) from titles) < $30
BEGIN
    UPDATE titles
       SET price = price * 2
    SELECT MAX(price) from titles
    IF (SELECT MAX(price) from titles) > $50
       BREAK
    ELSE
       CONTINUE
END
PRINT 'Too much for the market to bear'
B. ÔÚ´øÓÐÓαêµÄ¹ý³ÌÖÐʹÓà WHILE
ÒÔÏ嵀 WHILE ½á¹¹ÊÇÃûΪ count_all_rows ¹ý³ÌÖеÄÒ»²¿·Ö¡£ÏÂÀýÖУ¬¸Ã WHILE ½á¹¹²âÊÔÓÃÓÚÓαêµÄº¯Êý @@FETCH_STATU


Ïà¹ØÎĵµ£º

MySqlµÄ¼òµ¥Ð޸ıí×Ö¶ÎSQLÓï¾ä

#ÐÂÔöÒ»¸ö×ֶΣ¬Ä¬ÈÏֵΪ0£¬·Ç¿Õ£¬×Ô¶¯Ôö³¤£¬Ö÷¼ü
   alter table tabelname add new_field_name field_type default 0 not null auto_increment ,add primary key (new_field_name);
#Ôö¼ÓÒ»¸öÐÂ×Ö¶Î
   alter table tableName add new_field_name field_type;
   alter table tableNam ......

SQL SERVER 2005·ÖÒ³´æ´¢¹ý³Ì

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[PE011_Page]
  @TableName varchar(50),        --±íÃû
 @Fields varchar(5000) = '*',    --×Ö¶ÎÃû(È«²¿×Ö¶ÎΪ*)
 @OrderField varchar(5000),    &n ......

SQL ServerËÀËø

 1. ËÀËøÔ­Àí
    ¸ù¾Ý²Ù×÷ϵͳÖеĶ¨Ò壺ËÀËøÊÇÖ¸ÔÚÒ»×é½ø³ÌÖеĸ÷¸ö½ø³Ì¾ùÕ¼Óв»»áÊͷŵÄ×ÊÔ´£¬µ«Òò»¥ÏàÉêÇë±»ÆäËû½ø³ÌËùÕ¾Óò»»áÊͷŵÄ×ÊÔ´¶ø´¦ÓÚµÄÒ»ÖÖÓÀ¾ÃµÈ´ý״̬¡£
    ËÀËøµÄËĸö±ØÒªÌõ¼þ£º
»¥³âÌõ¼þ(Mutual exclusion)£º×ÊÔ´²»Äܱ»¹²Ïí£¬Ö»ÄÜÓÉÒ»¸ö½ø³ÌʹÓá£
ÇëÇóÓë±£³ÖÌ ......

sql server Ë÷Òý¹ÜÀíÁù´óÌúÂÉ


ÎÄÕÂÀ´Ô´£ºIT¹¤³Ì¼¼ÊõÍø http://www.systhinker.com/?viewnews-11609
      ÌúÂÉÒ»£ºÌìÏÂûÓÐÃâ·ÑµÄÎç²Í£¬Ê¹ÓÃË÷ÒýÊÇÐèÒª¸¶³ö´ú¼ÛµÄ¡£
 
¡¡¡¡Ë÷ÒýµÄÓŵãÓÐÄ¿¹²¶Ã£¬µ«ÊÇ£¬È´ºÜÉÙÓÐÈ˹ØÐĹý²ÉÓÃË÷ÒýËùÐèÒª¸¶³öµÄ³É±¾¡£ÈôÊý¾Ý¿â¹ÜÀíÔ±Äܹ»¶ÔË÷ÒýËùÐèÒª¸¶³öµÄ´ú¼ÛÓÐÒ»¸ö³ä·ÖµÄÈÏʶ£¬Ò²¾Í²»» ......

SAP ʹÓÃSQL Trace£¨ST05£©

SAP ʹÓÃSQL Trace£¨ST05£©
SAP R/3 Ìṩ±ê×¼ABAP SQL ¸ú×Ù¹¤¾ß¡£Ê¹ÓÃT-Code:ST05 ¿ÉÒÔ½øÈë×·×ÙÉ趨»­Ã棺
 
         ÔÚTrace Modes ÇøÓòÖÐÑ¡ÔñÐèÒªÔÚSAP R/3 Server ÉÏtrace µÄ·¶Î§£º
         SQL Trace: ×·×Ù¸ÃA ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ