SQL Server DATEDIFF() º¯Êý
¶¨ÒåºÍÓ÷¨
DATEDIFF() º¯Êý·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄÌìÊý¡£
Óï·¨
DATEDIFF(datepart,startdate,enddate)
startdate ºÍ enddate ²ÎÊýÊǺϷ¨µÄÈÕÆÚ±í´ïʽ¡£
datepart ²ÎÊý¿ÉÒÔÊÇÏÂÁеÄÖµ£º
datepart
Ëõд
Äê
yy, yyyy
¼¾¶È
qq, q
ÔÂ
mm, m
ÄêÖеÄÈÕ
dy, y
ÈÕ
dd, d
ÖÜ
wk, ww
ÐÇÆÚ
dw, w
Сʱ
hh
·ÖÖÓ
mi, n
Ãë
ss, s
ºÁÃë
ms
΢Ãî
mcs
ÄÉÃë
ns
select convert(varchar,datediff(s,'2009-12-15',getdate())/3600)+'Сʱ'+
convert(varchar,datediff(s,'2009-12-15',getdate())%3600/60)
+'·ÖÖÓ'
+
convert(varchar,datediff(s,'2009-12-15',getdate())%3600%60)
+'Ãë'
Ïà¹ØÎĵµ£º
alert index mem_ct monitoring usage;
desc v$object_usage;
set linesize 190
select * from v$object_usage;
SQL>SET AUTOTRACE ON;
¡¡¡¡*autotrace¹¦ÄÜÖ»ÄÜÔÚSQL*PLUSÀïʹÓÃ
¡¡¡¡ÆäËûһЩʹÓ÷½·¨£º
¡¡¡¡2.2.1¡¢ÔÚSQLPLUSÖеõ½Óï¾ä×ܵÄÖ´ÐÐʱ¼ä
¡¡¡¡SQL> set timing on;
2.2.2¡¢Ö»ÏÔʾִÐмƻ®--(»áÍ¬Ê ......
1¡¢²éѯÁ½¸öʱ¼äÖ®¼ä
select * from [tablename] where date between \'value1\' and \'value2\'
2¡¢ÏÔʾ×îºó»Ø¸´Ê±¼ä
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
3¡¢Èճ̰²ÅÅÌáÇ°5·ÖÖÓÌáÐÑ
select * from Èճ̰²ÅÅ w ......
--ºÏ²¢ÐУ¬²¢·µ»ØºÏ²¢µÄÖµ
Create proc [dbo].[proUniteRow]
@tab varchar(30), --±íÃû
@col varchar(30), --ºÏ²¢µÄÁÐÃû
@where varchar(2000), &nbs ......
½ñÌìÔÚÅäÖÃÊý¾Ý¿â·¢²¼ºÍ·Ö·¢Ê±×ÜÊDZ¨³öÏÖ 18483 ´íÎó
Ìáʾ˵£º´íÎó 18483:δÄÜÁ¬½Óµ½·þÎñÆ÷ "XXX"£¬ÒòΪ 'distributor_admin'δÔڸ÷þÎñÆ÷É϶¨ÒåΪԶ³ÌµÇ½¡£
Îҵķ¢²¼ºÍ·Ö·¢ÊÇͬһ¸ö·þÎñÆ÷£¬"XXX" ΪÎҵĻúÆ÷Ãû£¬·Ö·¢Êý¾Ý¿âÊÇĬÈϵÄÃû³Æ£¬¶øÎÒÔÚÁíÍâһ̨»úÆ÷ÉÏ×öʱ¾ÍÕý³£¡£
1¡¢ÉèÖù²Ïí¸´ÖÆĿ¼:
......
´¦ÀíÍøÕ¾²éѯ°üº¬”Ö®”×Ö³öÏ֔ȫÎÄËÑË÷Ìõ¼þÖаüº¬¸ÉÈÅ´Ê”ÏÖÏóµÄ×ܽ᣺
author:perfectaction
Sql server 2008È«ÎÄË÷ÒýµÄ¸ÉÈŴʱíĬÈÏÔÚResource¿âϵͳ±íÄÚ£¬ÎÞ·¨¸ü¸Ä£¬µ«sql2008ÌṩÁË×Ô¶¨Òå¸ÉÈŴʱíµÄ¹¦ÄÜ£¬¿É°ó¶¨µ½Ä³¸öÈ«ÎÄË÷ÒýÉÏ¡£
Ïà¹Ø²Ù×÷ÈçÏ£º
--sql server 2008 È«ÎÄË÷Òý½¨Á¢¼°´´½¨È«ÎÄ ......