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

¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨

  
  ¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨    
  1   :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ    
   
  eg:       Select   *   from   tableName    
                    Exec('select   *   from   tableName')    
                    Exec   sp_executesql   N'select   *   from   tableName'         --   Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN    
   
  2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL    
   
  eg:        
  declare   @fname   varchar(20)    
  set   @fname   =   'FiledName'    
  Select   @fname   from   tableName                             --   ´íÎó,²»»áÌáʾ´íÎ󣬵«½á¹ûΪ¹Ì¶¨ÖµFiledName,²¢·ÇËùÒª¡£    
  Exec('select   '   +   @fname   +   '   from   tableName')           --   Çë×¢Òâ   ¼ÓºÅǰºóµÄ   µ¥ÒýºÅµÄ±ßÉϼӿոñ    
   
  µ±È»½«×Ö·û´®¸Ä³É±äÁ¿µÄÐÎʽҲ¿É    
  declare   @fname   varchar(20)    
  set   @fname   =   'FiledName'   --ÉèÖÃ×Ö¶ÎÃû    
   
  declare   @s   varchar(1000)    
  set   @s   =   'select   '   +   @fname   +   '   from   tableName'    
  Exec(@s)                                 --   ³É¹¦    
  exec   sp_executesql   @s       --   ´


Ïà¹ØÎĵµ£º

SQL SERVERÖн»ºÍ²îµÄʵÏÖ

create table aaa
(
id int primary key ,
name varchar(30) not null
)
create table bbb
(
id int primary key ,
name varchar(30) not null
)
--½»
select * from aaa
where exists
(
select * from bbb where aaa.id=bbb.id and aaa.name = bbb.name
)
--²î
select *
from bbb
where not exists
( ......

sqlÓï¾ä¼¯ºÏ

A¡£
SQLÓï¾äµÄ²¢¼¯UNION£¬½»¼¯JOIN(ÄÚÁ¬½Ó£¬ÍâÁ¬½Ó)£¬½»²æÁ¬½Ó(CROSS
JOINµÑ¿¨¶û»ý)£¬²î¼¯(NOT IN)
1.
a. ²¢¼¯UNION
SELECT column1, column2 from table1
UNION
SELECT column1, column2 from table2
b. ½»¼¯JOIN
SELECT * from table1 AS a JOIN table2 b ON a.name=b.name
c. ²î¼¯NOT IN
SELECT * from tabl ......

linq to sql ÖеÄin ²Ù×÷ʵÏÖ


        string s = " 80,81,83,82";
        string[] s1 = s.Split(',');
        int[] p = new int[s1.Count()];
        for (int i = 0; i < s1.Count( ......

sqlÐÐÁл¥×ª(תÌû)

--ÐÐÁл¥×ª
/******************************************************************************************************************************************************
ÒÔѧÉú³É¼¨ÎªÀý×Ó£¬±È½ÏÐÎÏóÒ×¶®
ÕûÀíÈË£ºÖйú·ç(Roy)
ÈÕÆÚ:2008.06.06
***************************************************************** ......

Orcale µÄSQL Óï¾äÈ¡µÃϵͳµ±Ç°Ê±¼äÓãºsysdate

Orcale µÄSQL Óï¾äÈ¡µÃϵͳµ±Ç°Ê±¼äÓãºsysdate
    µ±ÐèÒªÔÚϵͳµ±Ç°ÈÕÆÚÉϼõÈ¥Ò»Ììʱ¿ÉÒÔÓà  sysdate-1
     ¸½£ºµ±Ö»¶ÔÒ»¶¨ÊýÁ¿µÄ¼Ç¼¸ÐÐËȤʱ¿ÉÒÔÈç rownum<100
select * from SLYC_CUSTINFO_T where indbtime>sysdate-1 and OFFICE_CODE='46' and rownum<1 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ