Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 2005 ÈçºÎÆô¶¯·þÎñ

1.¡¸¿ªÊ¼¡¹²Ëµ¥->ÔËÐÐ
--Æô¶¯sql server 2005 ·þÎñ
net start mssqlserver
--Í£Ö¹sql server 2005 ·þÎñ
net stop mssqlserver
2.¡¸¿ªÊ¼¡¹²Ëµ¥->³ÌÐò->Microsoft SQL Server 2005->ÅäÖù¤¾ß
SQL Server Configuration Manager->SQL Server(MSSQLSERVER) ÓÒ»÷ Æô¶¯·þÎñ³É¹¦ºó£¬×´Ì¬ÏÔʾΪ“ÕýÔÚÔËÐ ......

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 ServerÖÐÈçºÎÊä³öÐкÅ


Ô­ÎĵØÖ·£ºhttp://www.dingos.cn/index.php?topic=1688.0
OracleÓÐrownumÓÃÓÚ·ÃÎʱíÖÐÐкš£ÄÇôÔÚSQL ServerÖÐÊÇ·ñÓеÈЧµÄÄØ£¿»òÕßÔÚSQL ServerÖÐÈçºÎÊä³öÐкţ¿
-----------------------------------
ÔÚSQL ServerÖÐûÓÐÖ±½ÓµÈЧÓÚOracleµÄrownum
-----------------------------------
Ñϸñ˵À´£¬ÔÚ¹ØÏµÊý¾Ý¿âÖУ ......

delphi_sql_Óαê·ÖÒ³_·ÖÒ³dbgrid²éѯ

alter procedure qry_page
  @sqlstr nvarchar(4000),     --²éѯ×Ö·û´®
  @page int,                  --µÚNÒ³
  @pagesize int         &n ......

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ºÅ