ÖØдSQL Server DateDiffº¯Êý
--½«ÏµÍ³datediffº¯ÊýÖØд£¬Ö÷Òª°ÑdatepartÀàÐ͸ÄΪvarhcar£¬·½±ãµ÷ÓÃ
--×÷Õß:°½Ê¿Î°
--Date:2009-10-14 10:29
create function MyDateDiff(@datepart varchar(50), --ÈÕÆÚ¼ä¸ôÀàÐÍ:year,month,day.etc
@date1 varchar(50), @date2 varchar(50))
returns int
as
begin
declare @part int
if @datepart='year'
begin
set @part=datediff(year,@date1,@date2)
end
if @datepart='month'
begin
set @part=datediff(month,@date1,@date2)
end
if @datepart='day'
begin
set @part=datediff(day,@date1,@date2)
end
if @datepart='week'
begin
set @part=datediff(week,@date1,@date2)
end
if @datepart='hour'
begin
set @part=datediff(hour,@date1,@date2)
end
if @datepart='minute'
begin
set @part=datediff(minute,@date1,@date2)
end
if @datepart='second'
begin
set @part=datediff(second,@date1,@date2)
end
return(@part)
end --½áÊøº¯Êý¶¨Òå
Ïà¹ØÎĵµ£º
SQL*PLus> desc emp;
Ãû³Æ &nbs ......
°²×°Íê±ÏÖ®ºó£¬»¹ÐèÒªÉèÖÃһϲÅÄÜʹsql·þÎñÁ´½Ó³É¹¦¡£ Ñ¡ÔñµÚÒ»¸ö£º·þÎñºÍÁ´½ÓµÄÍâΧӦÓÃÅäÖÃÆ÷ µã»÷¡°Ô¶³ÌÁ´½Ó¡±£¬ÔÙÑ¡Ôñ±¾µØÁ´½ÓºÍÔ¶³ÌÁ´½Ó¡£Ñ¡ÔñµÚ3¸öÑ¡Ïî¡£ ºÃÁË¡£ÎÒÃÇ¿ÉÒÔµ½¿ªstudioÁË¡£ ¼ÇµÃÔÚ·þÎñÆ÷Ãû³ÆÊäÈ룺localhost\SQLEXPRESS
µÇ¼Ãûsa¡£ÃÜÂë¾ÍÊÇ°²×°µÄʱºòÊäÈëµÄÃÜÂë¡£ ok¡£¡£¡£ºÃÁË¡£¡£¡£¡ ......
Èç¹ûÄã¾³£Óöµ½ÏÂÃæµÄÎÊÌ⣬Äã¾ÍÒª¿¼ÂÇʹÓÃSQL ServerµÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLÏ°¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......
SQL ServerÆóÒµ°æ/±ê×¼°æ/¸öÈË°æµÄÇø±ð
http://blog.163.com/meteor_zc/blog/static/33150220200811291738603/
SQL ServerÆóÒµ°æ/±ê×¼°æ/¸öÈË°æµÄÇø±ð£¿--Î÷²¿EÍøweste.net¡¡2008-12-29 01:07
·ÖÀࣺĬÈÏ·ÖÀà ×ֺţº ´ó´ó ÖÐÖРСС SQL ServerÆóÒµ°æ/±ê×¼°æ/¸öÈË°æµÄÇø±ð£¿
¡¡¡¡¶ÔÓÚнӴ¥SQLÊý¾Ý¿â ......
SQLÖ®ÐÐÁл¥±äÎÊÌâ¡£
Ñ°Ñ°ÃÙÃÙ£¬SQLÐбäÁУ¬ÁбäÐÐÎÊÌâËäÈ»½â¾ö·½°¸Öڶ࣬µ«ÎÞ²»´æÔÚ×Å´úÂ븴ÔÓ£¬ÐÔÄÜÇ·¼ÑµÈÎÊÌâ¡£½ñÓÐÐÒµÃÖª×î¼Ñ½â¾ö·½°¸£¬ºÃ¶«Î÷²»¸Ò¶ÀÏí£¬±Ê¼ÇÖ®£¬ÑÅË×¹²ÉÍ¡£
ʾÀýÊý¾Ý£º£¨¸ÃʾÀýÊý¾ÝÀ´×ÔYHHRÊý¾Ý¿â Performance_Zmonth_Value±í£©
Employee_Id& ......