Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Êý¾ÝÂÒÂëÎÊÌâ

¹úÍâ¿Õ¼äÃ²ËÆ¶ÔÖÐÎıȽϸÐð Èç¹ûÊý¾ÝÀàÐÍÉè¼ÆÎª varchar ÀàÐ͵ϰ ´æ´¢µÄÊý¾Ý»ù±¾ÉÏÊÇ  "£¿£¿£¿£¿"
ºÜ¼òµ¥ ½« varchar ÀàÐÍ Éè¼ÆÎª nvarchar ÀàÐÍ
create table cs
(
   txt1 nvarchar(50) null
)
insert into cs (txt1 ) values ('²âÊÔ')  -- Èë¿âʱÊý¾Ýʱ £¿£¿£¿£¿
insert into cs (txt ......

SQL·ÖÒ³


SQL·ÖÒ³
ÍòÄÜ·ÖÒ³
.net´úÂë
select top Ã¿Ò³ÏÔʾµÄ¼Ç¼Êý * from topic where id not in     
 (select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id desc)  ......

SQL Êý¾Ý¿â¿ª·¢Ò»Ð©¾«µäµÄ´úÂë

1.°´ÐÕÊϱʻ­ÅÅÐò: Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ: select encrypt('ԭʼÃÜÂë') select pwdencrypt('ԭʼÃÜÂë') select pwdcompare('ԭʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ
3.È¡»Ø±íÖÐ×Ö¶Î: declare @list varchar(1000),@sql nvarchar(1000)&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ