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

sql ʱ¼äº¯Êý£¨×ª£©

sqlÈÕÆÚº¯Êý(ת)
[ 2007-8-23 16:33:00 | By: ²½ ]1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
4.¼¾¶ÈµÄµÚÒ»Ìì
Select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
5.µ±ÌìµÄ°ëÒ¹
Select DATEADD(dd, DATEDIFF(dd,0,getdate()), 0)
6.ÉϸöÔµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
7.È¥ÄêµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))
8.±¾ÔµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))
9.±¾ÄêµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1, 0))
10.±¾ÔµĵÚÒ»¸öÐÇÆÚÒ»
select DATEADD(wk, DATEDIFF(wk,0,dateadd(dd,6-datepart(day,getdate()),getdate())), 0)
·µ»Øµ±Ç°ÈÕÆÚºÍʱ¼ä
ͨ¹ýº¯ÊýGETDATE£¨£©£¬Äã¿ÉÒÔ»ñµÃµ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£º¯ÊýGETDATE£¨£©¿ÉÒÔÓÃÀ´×÷ΪDATEDIMEÐÍ×ֶεÄȱʡֵ¡£Õâ¶Ô²åÈë¼Ç¼ʱ±£´æµ±Ê±µÄ
ʱ¼äÊÇÓÐÓõġ£Òª½¨Á¢Ò»¸ö±í£¬ÆäÖеļǼ°üº¬Óе±Ç°µÄÈÕÆÚºÍʱ¼ä£¬¿ÉÒÔÌí¼ÓÒ»¸öDATETIMEÐÍ×ֶΣ¬Ö¸¶¨ÆäȱʡֵΪº¯ÊýGETDATE£¨£©µÄ·µ»Ø
Öµ£¬¾ÍÏóÕâÑù£º
Create TABLE site_log (
username VARCHAR(40)£¬
useractivity VARCHAR(100)£¬
entrydate DATETIME DEFAULT GETDATE())
ת»»ÈÕÆÚºÍʱ¼ä
º¯ÊýGETDATE£¨£©µÄ·µ»ØÖµÔÚÏÔʾʱֻÏÔʾµ½Ã롣ʵ¼ÊÉÏ£¬SQL SeverÄÚ²¿Ê±¼ä¿ÉÒÔ¾«È·µ½ºÁÃ뼶£¨È·ÇеØ˵£¬¿ÉÒÔ¾«È·µ½3.33ºÁÃ룩¡£
ÒªµÃµ½²»Í¬¸ñʽµÄÈÕÆÚºÍʱ¼ä£¬ÄãÐèҪʹÓú¯ÊýCONVERT£¨£©¡£ÀýÈ磬µ±ÏÂÃæµÄÕâ¸öÓï¾äÖ´ÐÐʱ£¬ÏÔʾµÄʱ¼ä½«°üÀ¨ºÁÃ룺
Select CONVERT(VARCHAR(30)£¬GETDATE()£¬9)
×¢ÒâÀý×ÓÖÐÊý×Ö9µÄʹÓá£Õâ¸öÊý×ÖÖ¸Ã÷ÁËÔÚÏÔʾÈÕÆÚºÍʱ¼äʱʹÓÃÄÄÖÖÈÕÆÚºÍʱ¼ä¸ñʽ¡£µ±Õâ¸öÓï¾äÖ´ÐÐʱ£¬½«ÏÔʾÈçϵÄÈÕÆÚºÍʱ¼ä£º
Nov 30 1997 3:29:55:170AM
(1 row(s) affected)
ת»»ÈÕÆÚºÍʱ¼ä
º¯ÊýGETDATE£¨£©µÄ·µ»ØÖµÔÚÏÔʾʱֻÏÔʾµ½Ã롣ʵ¼ÊÉÏ£¬SQL SeverÄÚ²¿Ê±¼ä¿ÉÒÔ¾«È·µ½ºÁÃ뼶£¨È·ÇеØ˵£¬¿ÉÒÔ¾«È·µ½3.33ºÁÃ룩¡£
ÒªµÃµ½²»Í¬¸ñʽµÄÈÕÆÚºÍʱ¼ä£¬ÄãÐèҪʹÓú¯ÊýCONVERT£¨£©¡£ÀýÈ磬µ±ÏÂÃæµÄÕâ¸öÓï¾äÖ´ÐÐʱ£¬ÏÔʾµÄʱ¼ä½«°üÀ¨ºÁÃ룺
Select CONVERT(VARCHAR(30)£¬GETDATE()£¬9)
×¢ÒâÀý×ÓÖÐÊý×Ö9µÄʹÓá£Õâ¸öÊý


Ïà¹ØÎĵµ£º

select * into ºÍinsert into SQL SERVER

select * into destTbl from srcTbl
insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl
ÒÔÉÏÁ½¾ä¶¼Êǽ« srcTbl µÄÊý¾Ý²åÈëµ½ destTbl£¬µ«Á½¾äÓÖÓÐÇø±ðµÄ£º
µÚÒ»¾ä£¨select into from£©ÒªÇóÄ¿±ê±í£¨destTbl£©²»´æÔÚ£¬ÒòΪÔÚ²åÈëʱ»á×Ô¶¯´´½¨¡£
µÚ¶þ¾ä£¨insert into select from£©ÒªÇóÄ¿±ê±í£¨dest ......

SQL ServerµÄһЩϵͳ±äÁ¿

SQL ServerµÄһЩϵͳ±äÁ¿
sp_configure 'min server memory' --·þÎñÆ÷×îСÄÚ´ægosp_configure 'max server memory' --·þÎñÆ÷×î´óÄÚ´æ'gosp_configure 'index create memory'--´´½¨Ë÷ÒýÕ¼ÓõÄÄÚ´ægo--sp_configure 'min  memory per query'--ÿ´Î²éѯռÓõÄ×îСÄÚ´æ
--»ñÈ¡I/O¹¤×÷Çé¿öselect --  @@id_bus ......

Sql Server 2005Êý¾Ý¿â±»±ê¼ÇΪ¡°¿ÉÒÉ¡±ÎÊÌâ


ÎÊÌâ±³¾°£º
¡¡¡¡ÈÕ³£¶ÔSql Server 2005¹ØϵÊý¾Ý¿â½øÐвÙ×÷ʱ£¬ÓÐʱ¶ÔÊý¾Ý¿â£¨È磺SharepointÍøÕ¾ÅäÖÃÊý¾Ý¿âÃû
Sharepoint_Config£©½øÐÐЩ²»Õý³£²Ù×÷ÈçÊý¾Ý¿âÔÚ¶Áдʱ¶øÎÞ¹ÊÍ£Ö¹Êý¾Ý¿â£¬´Ó¶øµ¼ÖÂSql Server 2005Êý¾Ý¿â²»Õý³£
Öжϣ¬µ±Ôٴδò¿ªÊý¾Ý¿âʱ»á·¢ÏÖijЩÊý¾Ý¿â»á±»±ê¼ÇΪ“¿ÉÒÉ”£¨suspect)£¬¼´ÔÚÊý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ