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

SQL Server²éѯһÖÜÄڵļǼ

select * from tableName where datediff(week,dateField,getdate())=0
ÕâÑù²é³öÀ´µÄ½á¹ûÊÇ´ÓÐÇÆÚÌìµ½ÐÇÆÚÁù(ÀÏÍâĬÈÏÐÇÆÚÌìÊÇÒ»ÖܵĵÚÒ»Ìì).
Èç¹ûÏëÒÔÐÇÆÚÒ»×÷ΪµÚÒ»ÌìµÄ»°,Á½¸öʱ¼ä¶¼ÐèÒª¼õÒ»,ÈçÏÂ:
select * from tableName where datediff(week,dateField-1,getdate()-1)=0


Ïà¹ØÎĵµ£º

sql ²éѯ³öÀ´Ò»¸ö±íÔÚ²åÈëµ½ÁíÒ»¸ö±íÀï

ALTER  FUNCTION  [dbo].[fun_tongji]()
RETURNS  @t1 table (
  yue int ,
  money int
 )
AS
begin
 Declare @i int
 set @i=1
-- declare @t1 table (
--  yue int ,
--  money int
-- )
 while (@i<=12)&n ......

DB2´íÎóÐÅÏ¢»ã×Ü SQL CODEºÍSQL StateÏà¹Ø[ת]

²Ù×÷Êý¾Ý¿â¹ý³ÌÖУ¬Óöµ½Ðí¶àÎÊÌ⣬ºÜ¶à¶¼ÓëSQL CODEºÍSQL StateÏà¹Ø£¬ÏÖÔÚ°ÑÒ»¸öÍêÕûµÄSQLCODEºÍSQLState´íÎóÐÅÏ¢ºÍÏà¹Ø½âÊÍ×÷ÒÔÏÂ˵Ã÷£¬Ò»À´¿ÉÒÔ×Ô¼º²Î¿¼£¬¶ÔDB2´íÎó×ÔÐÐÕÒ³öÔ­Òò
£¨ÉùÃ÷£ºÕâÊÇËѼ¯ÍøÉϵÄ×ÊÁϵÃÀ´µÄ,Ïêϸ³ö´¦²»¼ÇµÃÁË£©
sqlcode sqlstate ˵Ã÷
000 00000 SQLÓï¾ä³É¹¦Íê³É
01xxx SQLÓï¾ä³É¹¦Íê³É£¬µ«ÊÇÓ ......

MS SQL ServerÈÕÆÚ¼ÆËã

ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆںͼÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃǴ󲿷ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡ÔÚÕâƪÎÄÕÂÀÎÒ½«¸æËßÄãÈçºÎʹÓÃDATEADDºÍ DATEDIFFº¯ÊýÀ´¼ÆËã³öÔÚÄãµÄ³ÌÐò ......

PL/SQLÓαê±äÁ¿µÄµ÷ÓÃÓë×÷ΪÊä³ö²ÎÊýµÄÓ¦ÓÃ

      ½ñÌìÓиöѧÉúÎÊÎÒµ÷ÓðüÀïÃæ¾ßÓÐÓαêÀàÐ͵ÄÊä³ö²ÎÊý£¬¿ÉÊÇÔÚÓÃPL/SQL³ÌÐòµ÷ÓõÄʱºò¾ÓÈ»±¨³ö²ÎÊý¸öÊý»òÀàÐÍ´íÎóµÄÒì³£ÐÅÏ¢£¬ÓÚÊÇ×Ô¼ºÒ²ÊÔÁËһϣ¬¹ûÈ»Êdzö´íÁË¡£È»ºó¾Í×Ô¼º×ÁÄ¥ÁËһϡ¢²é²é×ÊÁϺÍÎÊÎÊͬÊ£¬Ô­À´ÎÊÌâÊǺܼòµ¥µÄ£¬ÏÈ¿´Ò»Ï³ÌÐòµÄ½á¹¹´úÂ룺
CREATE OR REPLACE PACKAGE Pkg_S ......

SQL ServerÖÐcaseµÄÓ÷¨

µÚÒ»ÖÖÓ÷¨£º
SELECT (CASE type WHEN 'u' THEN 'Óû§±í' WHEN 's' THEN 'ϵͳ±í' ELSE 'ÆäËû' END) AS TABLEKIND,* from SYSOBJECTS
µÚ¶þÖÐÓ÷¨£º
SELECT (CASE WHEN crdate<'2006-01-01' THEN 'early' WHEN crdate<'2009-01-01' THEN 'nearly' ELSE 'now' END) AS PERIOD,* from SYSOBJECTS ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ