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

Sql ²éѯµ±Ìì¡¢±¾ÖÜ¡¢±¾Ô¼Ç¼

Sql´úÂë:Powered by chenjiazi
--²éѯµ±Ì죺   
select * from info where DateDiff(dd,datetime,getdate())=0   
  
--²éѯ24СʱÄÚµÄ:   
select * from info where DateDiff(hh,datetime,getDate())<=24   
  
--infoΪ±íÃû,datetimeΪÊý¾Ý¿âÖеÄ×Ö¶ÎÖµ  
--²éѯµ±Ì죺select * from info where DateDiff(dd,datetime,getdate())=0--²éѯ24СʱÄÚµÄ:select * from info where DateDiff(hh,datetime,getDate())<=24--infoΪ±íÃû,datetimeΪÊý¾Ý¿âÖеÄ×Ö¶ÎÖµ
 
Sql´úÂë Powered by chenjiazi
 
--²éѯµ±Ìì¼Ç¼ÁíÀàµÄ·½·¨   
SELECT *   
from j_GradeShop   
WHERE (GAddTime BETWEEN CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000')   
      AND CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000') + 1)   
ORDER BY GAddTime DESC   
--²éѯµ±Ìì¼Ç¼ÁíÀàµÄ·½·¨SELECT *from j_GradeShopWHERE (GAddTime BETWEEN CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000') AND CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000') + 1)ORDER BY GAddTime DESC
DATEDIFF º¯Êý:
Óï·¨:
 
DATEDIFF ( datepart , startdate , enddate )
±¸×¢:
 
enddate ¼õÈ¥ startdate¡£Èç¹û startdate ÍíÓÚ enddate£¬Ôò·µ»Ø¸ºÖµ¡£
Èç¹û½á¹û³¬³öÕûÊýÖµ·¶Î§£¬Ôò DATEDIFF ½«²úÉú´íÎ󡣶ÔÓÚºÁÃ룬×î´óÊýÊÇ 24 Ìì 20 Сʱ 31 ·ÖÖÓÁã 23.647 Ãë¡£¶ÔÓÚÃ룬×î´óÊýÊÇ 68 Äê¡£
¿ç·ÖÖÓ¡¢ÃëºÍºÁÃëµÈ±ß½ç¼ÆËãµÄ·½·¨Ê¹µÃ DATEDIFF Ö¸¶¨µÄ½á¹ûÔÚËùÓÐÊý¾ÝÀàÐÍÖоùÒ»Ö¡£½á¹ûÊÇ´øÕý¸ººÅµÄÕûÊýÖµ£¬ËüµÈÓÚ¿çµÚÒ»¸öºÍµÚ¶þ¸öÈÕÆÚ¼äµÄ datepart ±ß½çÊý¡£ÀýÈ磬ÔÚ 1 Ô 4 ÈÕ£¨ÐÇÆÚÈÕ£©ºÍ 1 Ô 11 ÈÕ£¨ÐÇÆÚÈÕ£©Ö®¼äµÄÐÇÆÚÊýÊÇ 1¡£
¿ÉÒÔÔÙMSSQLÖвâÊÔ:
Sql´úÂë
 
--Á½¸öʱ¼ä²î¸ÕºÃÊÇ24   
--´òÓ¡µÄ·½Ê½   
print dateDiff(hh,'2009-1-1 0:0:0','2009-1-2 0:0:0')   
  
--²éѯµÄ·½Ê½   
print dateDiff(hh,'2009-1-1 0:0:0','2009-1-2 0:0:0')  
--Á½¸öʱ¼ä²î¸ÕºÃÊÇ24--´òÓ¡µÄ·½Ê½print dateDiff(hh,'2009-1-1 0:0:0','2009-1-2 0:


Ïà¹ØÎĵµ£º

sqlÈÕÆÚÄ£ºý²éѯ SQLʱ¼äת»»¸ñʽ

Select * from t_user_profile where convert ( varchar ( 21 ),regDate, 120 ) like ' 2008-05-07% ' ±íÃû³Æ£ºt_user_profile ÈÕÆÚ×Ö¶ÎÃû³Æ£ºregDate
Select   *   from t_user_profile  where  convert(varchar(21),regDate,120) like '2008-05-07%'< ......

sqlº¯Êý¡¡

1¡¢ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_valueÔÚ check_expressionΪNULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë check_expresssion ¾ßÓÐÏàͬµÄÀàÐÍ¡£
·µ»ØÀàÐÍ
·µ»ØÓë check_expression Ï ......

ÁíÀà¼òµ¥µÄSQLÊý¾Ý¿â¸ÄÃû·½·¨

°ÑOldÊý¾Ý¿â¸ÄΪNewÊý¾Ý¿â
1.´ò¿ª“ÆóÒµ¹ÜÀíÆ÷”ÕÒµ½ OldÊý¾Ý¿â£­£­¡·ÓÒ¼ü£­£­¡·ËùÓÐÈÎÎñ£­£­¡··ÖÀëÊý¾Ý¿â
2.µ½C:\Program Files\Microsoft SQL Server\MSSQL\DataÏÂÕÒµ½Old_Data.mdfºÍOld_log.ldf°ÑOld_Data»»³ÉÄãÏëÒªµÄÃû×ÖÀýÈçNew.mdf¡¢New.ldf
3.µ½ÆóÒµ¹ÜÀíÆ÷£¬ÕÒµ½ Êý¾Ý¿â £­£­¡·ÓÒ¼ü£­£­¡·ËùÓÐÈÎÎñ£­£­¡ ......

PL/SQLѧϰ±Ê¼ÇÁù


1.´´½¨¹ý³Ì
create or replace procedure ¹ý³ÌÃû as
   ÉùÃ÷Óï¾ä¶Î;
begin
   Ö´ÐÐÓï¾ä¶Î;
exception
   Òì³£´¦ÀíÓï¾ä¶Î;
end;
2. ´ø²ÎÊýµÄ¹ý³Ì
²ÎÊýÀàÐÍ3ÖÖ
in²ÎÊý£º¶ÁÈë²ÎÊý£¬Ö÷³ÌÐòÏò¹ý³Ì´«µÝ²ÎÊýÖµ
out²ÎÊý£ºÊä³ö²ÎÊý£¬¹ý³ÌÏòÖ÷³ÌÐò´«µÝ²ÎÊýÖµ
in out²ÎÊý£ºË«Ïò²ÎÊý
¶¨Òå ......

Sql service error 1069½â¾ö·½·¨

µ±ÐÞ¸ÄÁ˵ǼÃÜÂëʱ£¬µ±Æô¶¯mssqlserverµÄʱºò»á³öÏÖerror 1069, means logon error. ÕâÊÇÓÉÓÚÒ»ÏÂ2¸öÔ­Òò1.sqlserverµÄÃÜÂëûÓÐͬ²½µÄÔ­Òò£¬ÐèÒªÔÚadministrator tools ->services-> right click mssqlserver -> property-> logon tab -> change passward to new one . 2.sqlserverµÄÆô¶¯Óû§²»¶Ô£¬ÐèÒªÔÚa ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ