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

SQLÈÕÆÚºÍʱ¼äº¯Êý

 
--»ùÓÚʱ¼äSQLº¯Êý--
getdate() --·µ»Øµ±Ç°ÏµÍ³ÈÕÆÚºÍʱ¼ä¡£
DateAdd --ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ¡£
DATEADD ( datepart , number, date )
--Àý£ºÏòµ±ÌìµÄʱ¼äÔö¼Ó5Ìì
select dateadd(dd,5,getdate())
datediff --·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£]
---ÀýÈç
   select datediff(day, '2009-08-08', getdate())
DATEDIFF ( datepart , startdate , enddate )
--°Ñʱ¼ä×ֶεÄÊý¾Ý±äΪÄêÔÂ
Select Convert(Varchar(6),GetDate(),112)
--×Ö·û´®±äʱ¼ä
select convert(datetime,left(@t,len(@t)-4)+':'+left(right(@t,4),2)+':'+right(@t,2))
ISDATE --È·¶¨ÊäÈë±í´ïʽÊÇ·ñΪÓÐЧµÄÈÕÆÚ
DATEPART --·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý
DATEPART ( datepart , date )
--È磺·µ»Øµ±Ç°ÊǼ¸ÔÂ
select datepart(mm,getdate())
DATENAME --·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
--datepart ,datenameµÄÇø±ð£ºÇ°Õß·µ»ØÊÇÕûÊý£¬ºóÕß·µ»ØÊÇ×Ö·û´®¡£
 day(), month(),year() --¿ÉÒÔÓëdatepart¶ÔÕÕÒ»ÏÂ
select µ±Ç°ÈÕÆÚ=convert(varchar(10),getdate(),120)
,µ±Ç°Ê±¼ä=convert(varchar(8),getdate(),114)
select datename(dw,'2004-10-15')
select ±¾ÄêµÚ¶àÉÙÖÜ=datename(week,'2004-10-15')
,½ñÌìÊÇÖܼ¸=datename(weekday,'2004-10-15')
º¯Êý ²ÎÊý/¹¦ÄÜ
GetDate( ) ·µ»ØϵͳĿǰµÄÈÕÆÚÓëʱ¼ä
DateDiff (interval,date1,date2) ÒÔinterval Ö¸¶¨µÄ·½Ê½£¬·µ»Ødate2 Óëdate1Á½¸öÈÕÆÚÖ®¼äµÄ²îÖµ date2-date1
DateAdd (interval,number,date) ÒÔintervalÖ¸¶¨µÄ·½Ê½£¬¼ÓÉÏnumberÖ®ºóµÄÈÕÆÚ
DatePart (interval,date) ·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄÕûÊýÖµ
DateName (interval,date) ·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄ×Ö·û´®Ãû³Æ
²ÎÊý intervalµÄÉ趨ֵÈçÏ£º
Öµ Ëõ д£¨Sql Server£© Access ºÍ ASP ˵Ã÷
Year Yy yyyy Äê 1753 ~ 9999
Quarter Qq q ¼¾ 1 ~ 4
Month Mm m ÔÂ1 ~ 12
Day of year Dy y Ò»ÄêµÄÈÕÊý,Ò»ÄêÖеĵڼ¸ÈÕ 1-366
Day Dd d ÈÕ£¬1-31
Weekday Dw w Ò»ÖܵÄÈÕÊý£¬Ò»ÖÜÖеĵڼ¸ÈÕ 1-7
Week Wk ww ÖÜ£¬Ò»ÄêÖеĵڼ¸ÖÜ 0 ~ 51
Hour Hh h ʱ0 ~ 23
Minute Mi n ·ÖÖÓ0 ~ 59
Second Ss s Ãë 0 ~ 59
Millisecond Ms - ºÁÃë 0 ~ 999
 
1.GetDate() ÓÃÓÚsql server :select GetDate()
2.DateDiff('s','2


Ïà¹ØÎĵµ£º

¶¯Ì¬´´½¨Sql ServerÊý¾Ý¿âÏà¹Ø£¨È«£©

 
CREATE DATABASE
´´½¨Ò»¸öÐÂÊý¾Ý¿â¼°´æ´¢¸ÃÊý¾Ý¿âµÄÎļþ£¬»ò´ÓÏÈÇ°´´½¨µÄÊý¾Ý¿âµÄÎļþÖи½¼ÓÊý¾Ý¿â¡£
˵Ã÷ ÓйØÓë DISK INIT Ïòºó¼æÈÝÐԵĸü¶àÐÅÏ¢£¬Çë²Î¼û"Microsoft® SQL Server™ Ïòºó¼æÈÝÐÔÏêϸÐÅÏ¢"ÖеÄÉ豸£¨¼¶±ð 3£©¡£
Óï·¨
CREATE DATABASE database_name
[ ON
[ < filespec > ......

sql´óÈ«³¬Ïêϸ

  SQL ÃüÁî
Õⲿ·Ö°üº¬ÄÇЩ PostgreSQL Ö§³ÖµÄ SQL ÃüÁîµÄÐÅÏ¢£®ÕâÀïµÄ "SQL" ¾ÍÊǸÃÓïÑÔͨ³£µÄº¬Ò壻 ÿÌõÃüÁîµÄÓë±ê×¼ÓйصļæÈÝÐÔµÄÐÅÏ¢¿ÉÒÔÔÚÏà¹ØµÄ²Î¿¼Ò³ÖÐÕÒµ½£®
Table of Contents
ABORT --  Í˳öµ±Ç°ÊÂÎñ
ALTER GROUP --  Ïò×éÖÐÔö¼ÓÓû§»ò´Ó×éÖÐɾ³ýÓû§ 
ALTER USER --  ¸Ä±äÊý¾ ......

¶¯Ì¬SQL»ù±¾Óï·¨

 Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tableName -- ´íÎó,²»»áÌáʾ´í ......

sql server ÖÐɾ³ýĬÈÏÔ¼ÊøµÄͨÓÃsql½Å±¾

 ×÷Õߣº sealyu   ÈÕÆÚ£º2008-04-17
ÔÚSQL Server ÖУ¬Èç¹û¸ø±íµÄÒ»¸ö×Ö¶ÎÉèÖÃÁËĬÈÏÖµ£¬¾Í»áÔÚϵͳ±ísysobjectsÖÐÉú³ÉÒ»¸öĬÈÏÔ¼Êø¡£
Èç¹ûÏëɾ³ýÕâ¸öÉèÖÃÁËĬÈÏÖµµÄ×ֶΣ¨¼ÙÉè´Ë×Ö¶ÎÃûcolumn1£©£¬
Ö´ÐГALTER TABLE table1 DROP COLUMN column1”ʱ¾Í»á±¨´í£º
The object 'DF__xxxxxxxxxxx' ......

»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø

 
»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø ÊÕ²Ø
Õë¶ÔÊý¾Ý¿âÊý¾ÝÔÚUI½çÃæÉϵķÖÒ³ÊÇÀÏÉú³£Ì¸µÄÎÊÌâÁË£¬ÍøÉϺÜÈÝÒ×ÕÒµ½¸÷Ö֓ͨÓô洢¹ý³Ì”´úÂ룬¶øÇÒÓÐЩ»¹¶¨ÖƲéѯÌõ¼þ£¬¿´ÉÏȥʹÓúܷ½±ã¡£±ÊÕß´òËãͨ¹ý±¾ÎÄÒ²À´¼òµ¥Ì¸Ò»Ï»ùÓÚSQL SERVER 2000µÄ·ÖÒ³´æ´¢¹ý³Ì£¬Í¬Ê±Ì¸Ì¸SQL SERVER 2005Ï·ÖÒ³´æ´¢¹ý³ÌµÄÑ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ