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

SQL ×Ö·û´®²ð·Ö

       ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
 
        ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
 ------------------ɾ³ýÖظ´µÄ×Ö·û
 declare
@v1 nvarchar
(100)
declare
@v2 nvarchar
(100)
declare
@v3 nvarchar
(100)
declare 
@split nvarchar
(100)
--N',,,,,ÖÐ,¹ú,ÖÐ,ÈËÃñ,,,,,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú,,,'
set
@v1=N',  ,,     ,,ÖÐ,¹ú,ÖÐ,ÈËÃñ,  ,, ,    ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú,  ,,'
set
@v3=''
set
@split=','
/*
   @v1 :´æ´¢ÁÙʱ×Ö·û´®
   @v2 :»ñÈ¡Á½¸ö·Ö¸ô·ûÖеÄ×Ö·û´®
   @v3 :´æ´¢×îºóûÓÐÖظ´µÄ×Ö·û´®  
*/
if
left(@v1,1)<>@split
   set
@v1=@split+@v1
if
right(@v1,1)<>@split
   set
@v1=@v1+@split
while
len(@v1)>len(@split)*2
      begin
          set
@v2=substring
(@v1,len( @split),charindex
( @split,@v1,len
( @split)+1))
         if
len(@v2)>len
(@split)*2
            begin
              set
@v2=right
(@v2,len(@v2)-1);
              if
ltrim
(rtrim
(@v2))<>@split                
                 set
@v3=@v3+ltrim
(rtrim
(@v2));
              set
@v1= replace
(@v1,@v2,'')
            end
         else
--Èç¹ûÓÐÁ¬ÐøµÄ·Ö¸î·û,ɾ


Ïà¹ØÎĵµ£º

SQLÒ»¸ö´æ´¢¹ý³Ìµ÷ÓÃÁíÒ»¸ö´æ´¢¹ý³Ì »ñµÃ·µ»ØÖµÎÊÌâ

µÚÒ»ÖÖ·½·¨: ʹÓÃoutput²ÎÊý
USE AdventureWorks;
GO
IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL
    DROP PROCEDURE Production.usp_GetList;
GO
CREATE PROCEDURE Production.usp_GetList @product varchar(40)
    , @maxprice money
    , ......

½â¾öͬʱÐÞ¸ÄͬһSQL¼Ç¼µÄÎÊÌâ

ÔÚÑ°ÕÒPowerDesignerÏà¹ØÐÅÏ¢µÄʱºòżȻ·¢ÏÖµÄ.ʹÓÃtimestamp
΢ÈíMSDNÄÚÈÝ:
timestamp (Transact-SQL)
¹«¿ªÊý¾Ý¿âÖÐ×Ô¶¯Éú³ÉµÄΨһ¶þ½øÖÆÊý×ÖµÄÊý¾ÝÀàÐÍ¡£timestamp ͨ³£ÓÃ×÷¸ø±íÐмӰ汾´ÁµÄ»úÖÆ¡£ ´æ´¢´óСΪ 8 ¸ö×Ö½Ú¡£ timestamp Êý¾ÝÀàÐÍÖ»ÊǵÝÔöµÄÊý×Ö£¬²»±£ÁôÈÕÆÚ»òʱ¼ä¡£ ÈôÒª¼Ç¼ÈÕÆÚ»òʱ¼ä£¬ÇëʹÓà datetime ......

sql where ºÍon µÄÇø±ð

½ñÌìÔÚÂÛ̳ÄÚ¿´µ½Ò»Æª ÃæÊÔÌ⣬ÊǹØÓÚwhere ºÍon µÄÇø±ðµÄ£¬×Ô¼ºÒ²²»¶®£¬ÔÚÍøÉÏËѳöһƪÎÄÕ£¬¼ÓÉî×Ô¼ºµÄ¼ÇÒä
ת
Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
     ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þ ......

Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé

Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01','yyyy-mm-dd');
¡¡¡¡¡ôÔÚ¹ýÂËÌõ¼þÖУ¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐë·ÅÔÚwhere×Ó¾äµÄĩβ;
¡¡¡¡from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»× ......

select 1 from ... sqlÓï¾äÖеÄ1´ú±íʲôÒâ˼£¿

 select  1 from ...£¬ sqlÓï¾äÖеÄ1´ú±íʲôÒâ˼£¿²é³öÀ´ÊǸöʲô½á¹û£¿
        select 1 from table;Óëselect anycol(Ä¿µÄ±í¼¯ºÏÖеÄÈÎÒâÒ»ÐУ© from table;Óëselect * from table ´Ó×÷ÓÃÉÏÀ´ËµÊÇûÓвî±ðµÄ£¬¶¼ÊDz鿴ÊÇ·ñÓмǼ£¬Ò»°ãÊÇ×÷Ìõ¼þ²éѯÓõġ£select 1 from Ö ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ