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

SQLµ±Ç°ÈÕÆÚ»ñÈ¡¼¼ÇÉ

SQLµ±Ç°ÈÕÆÚ»ñÈ¡¼¼ÇÉ
select   getdate()   //2003-11-07   17:21:08.597    
  select   convert(varchar(10),   getdate(),120)   //2003-11-07  
  select   convert(char(8),getdate(),112)   //20031107  
  select   convert(char(8),getdate(),108)   //17:22:18 
select datepart(year,getdate()) //2007
µ±Ç°ÈÕÆÚ
select CONVERT(varchar(10), getdate(), 120)
Ò»¸öÔµÚÒ»ÌìµÄSQL ½Å±¾£º
     SELECT DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
±¾ÖܵÄÐÇÆÚÒ»
     SELECT DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
Ò»ÄêµÄµÚÒ»Ìì
     SELECT DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
¼¾¶ÈµÄµÚÒ»Ìì
     SELECT DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
µ±ÌìµÄ°ëÒ¹
     SELECT DATEADD(dd, DATEDIFF(dd,0,getdate()), 0)
ÉϸöÔµÄ×îºóÒ»Ìì
      SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
 
 
È¥ÄêµÄ×îºóÒ»Ìì
     SELECT dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))
±¾ÔµÄ×îºóÒ»Ìì
     SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))
±¾ÄêµÄ×îºóÒ»Ìì
     SELECT dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1, 0))¡£
±¾ÔµĵÚÒ»¸öÐÇÆÚÒ»
     select DATEADD(wk, DATEDIFF(wk,0,                           
                dateadd(dd,6-datepart(day,getdate()),getdate())  
                               &nb


Ïà¹ØÎĵµ£º

SQLʱ¼ä¶Î²éѯ


SQLʱ¼ä¶Î²éѯ
ACCESSµÄ»°
select * from table where date1<#2008-1-20# and date2>#2007-8-30#
MYSQLµÄ»°
select * from table where date1<'2008-1-20' and date2>'2007-3-30'
Ò²¿ÉÒÔ
select * from table where date1 between '2008-1-20' and '2007-3-30'
ÆäÖÐdate1,date2¶¼ÊÇÈÕÆÚÀàÐ͵Ä× ......

SQL SERVERÊý¾Ý¿âÖÐµÄ±í±¸·Ý³ÉÎı¾

--×÷ÓãºÊý¾Ý¿âÖÐµÄ±í±¸·Ý³ÉÎı¾
Declare @tabname varchar(200),@ip varchar(50),@user varchar(50),@password varchar(50),@sql varchar(1000),@filetxt varchar(200),@file varchar(50)
set @tabname='database.dbo.tb' --±íÃû
set @ip='127.0.0.1'  --IPµØÖ·£¬±¾»úµÄ»°¾Íд127.0.0.1
set @user='sa' ......

SQL ServerµÄ»Ö¸´Ä£Ê½

»Ö¸´Ä£Ê½£¨Recovery Model£©Ö¼ÔÚ¿ØÖÆÊÂÎñÈÕ־ά»¤¡£»Ö¸´Ä£Ê½ËµÃ÷Á˹¤×÷¶ªÊ§µÄ·çÏÕ£¬ÄÜ·ñ»Ö¸´µ½Ê±µã£¿ 
SQL ServerÊý¾Ý¿âÓÐÈýÖÖ»Ö¸´Ä£Ê½£º¼òµ¥»Ö¸´Ä£Ê½¡¢ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½¡£
Ïà¶ÔÓÚ¼òµ¥»Ö¸´Ä£Ê½¶øÑÔ£¬ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½ÌṩÁ˸üÇ¿µÄÊý¾Ý±£»¤¹¦ÄÜ¡£ÕâЩ»Ö¸´Ä£Ê½¶¼ÊÇ»ùÓÚ±¸·ÝÊÂÎñÈÕÖ ......

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

1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
      Àý:      Select * from tableName
                Exec('select * from tableName')
        & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ