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

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

1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
      Àý:      Select * from tableName
                Exec('select * from tableName')
                Exec sp_executesql N'select * from tableName'    -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
 
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
 
    ´íÎó:        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)                -- ³É¹¦
     


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

fastreport´òÓ¡´úÂë¼°SQLºÏ²¢×ֶεÄÓï¾ä

 procedure Tform1.Button5Click(Sender: TObject);
var
  p:pointer;
  FrfStr:string;
begin
  inherited;
  Screen.Cursor:=MYCURSORWAITHAND;
  with cdsPrint do
  begin
    Active:=false;
    //Õâ¸öSQLÓÃÓÚ½«remarkÖеļǼºÏ²¢µ½Ò»Æ ......

SQL ½ØÈ¡×Ö·û´®£¬ÖÐÎÄËãÁ½¸ö×Ö·ûµÄ·½·¨

--SQL ½ØÈ¡×Ö·û´®·½·¨£¬ÖÐÎÄËãÁ½¸ö×Ö·ûµÄ·½·¨¡£
--·½·¨¸úË®¸çѧϰµÄ£¬Ö§³ÖÒ»ÏÂË®¸çµÄ²©¿Í
--http://hi.csdn.net/link.php?url=http://blog.csdn.net%2Fwufeng4552
--Ë®¸ç×î½üлÁ˺ö಩¿Í£¬ÓÐʱ¼äÒ»¶¨È¥ºÃºÃѧϰ
--LEFT() ºÍSUBSTRING()¶¼Êǽ«ºº×ÖËãÒ»¸ö×Ö·ûÀ´ËãµÄ
--Èç¹û²»¼Æ½ÏµÄ»°£¬ÍƼöʹÓÃÕâÁ½¸öϵͳº¯Êý
IF OBJE ......

SQLÖظ´¼Ç¼²éѯ

SQLÖظ´¼Ç¼²éѯ
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from
people
where peopleId in (select   peopleId from   people group by   peopleId
having count
(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨p ......

SQLÁª±í¸üУ¬Áª±í²éѯ

ûÓÐÒýÓùØϵµÄ±í
 £±.¡¡Áª±í¸üÐÂ
update  a set a.education = '±¾¿Æ' from NT_UserInfo a ,NT_User b where  a.UserID=b.UserID and b.email = 'carlfan2008@163.com'
£².¡¡Áª±í²éѯ
select a.*,b.* from nt_user as a, nt_userinfo as b where a.userid = b.userid and Email = 'carlfan2008@163.com ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ