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

sql¶ÔÈÕÆÚʱ¼äµÄ²Ù×÷.¾ä¾ä¾­µä!

sqlµÃµ½µ±Ç°ÏµÍ³Ê±¼äµÃ ÈÕÆÚ²¿·Ö
CONVERT(varchar(10),getDate(),120)
ÇóµÃµ½"×òÌ죬½ñÌì"ÈÕÆÚº¯ÊýµÄSQL
ËùÊô·ÖÀࣺMS-SQL Server »ù´¡Àà
----------------------------------------------------------------------
Convert(Datetime,GetDate(),2)
GetDate()µÃµ½½ñÌìÈÕÆÚ2007-03-26 16:14:12.187
1.ÏÖÔÚÎÒÐèÒªµÃµ½Ö»ÊÇÈÕÆÚ²¿·Ö£¬Ê±¼ä²¿·Ö²»Òª£¬SQLÔõôд£¿
2.ÇóÒÔÏÂÈÕÆÚSQL:
×òÌì¡¡
Ã÷Ìì
×î½üÆßÌì
ËæºóÆßÌì
ÉÏÖÜ
±¾ÖÜ
ÏÂÖÜ
ÉÏÔÂ
±¾ÔÂ
ÏÂÔÂ
Çë¸ßÊÖ°ïæ¡£Ð»Ð»
----------------------------------------------------------------------
1.ÏÖÔÚÎÒÐèÒªµÃµ½Ö»ÊÇÈÕÆÚ²¿·Ö£¬Ê±¼ä²¿·Ö²»Òª£¬SQLÔõôд£¿
select convert(varchar(10),getdate(),120)
--------------------------------------------------------
--1.
Select Convert(Varchar(10), GetDate(), 120)
Select Convert(Varchar(10), GetDate(), 121)
--------------------------------------------------------
2.ÇóÒÔÏÂÈÕÆÚSQL:
×òÌì¡¡
select convert(varchar(10),getdate() - 1,120)
Ã÷Ìì
select convert(varchar(10),getdate() + 1,120)
×î½üÆßÌì
select * from tb where ʱ¼ä×Ö¶Î >= convert(varchar(10),getdate() - 7,120)
ËæºóÆßÌì
select * from tb where ʱ¼ä×Ö¶Î <= convert(varchar(10),getdate() + 7,120) and ʱ
¼ä×Ö¶Î >= ʱ¼ä×Ö¶Î
--------------------------------------------------------
convertºÍdateaddº¯Êý½áºÏʹÓþͿÉÒÔÁË¡£
--------------------------------------------------------
ÓÃdatediff(day,ʱ¼äÁÐ,getdate())
--------------------------------------------------------
ÉÏÔÂ
select * from tb where month(ʱ¼ä×Ö¶Î) = month(getdate()) - 1
±¾ÔÂ
select * from tb where month(ʱ¼ä×Ö¶Î) = month(getdate())
ÏÂÔÂ
select * from tb where month(ʱ¼ä×Ö¶Î) = month(getdate()) + 1
--------------------------------------------------------
--2
--Èç¹ûÊÇÔÚ±íÖвé詢
--×òÌì¡¡
Select * from TableName Where DateDiff(dd, DateTimCol, GetDate()) = 1
--Ã÷Ìì
Select * from TableName Where DateDiff(dd, GetDate(), DateTimCol) = 1
--×î½üÆßÌì
Select * from TableName Where DateDiff(dd, DateTimCol, GetDat


Ïà¹ØÎĵµ£º

SQLÓï¾äÐÔÄܵ÷ÕûÔ­Ôò

 Ò»¡¢ÎÊÌâµÄÌá³ö
    ÔÚÓ¦ÓÃϵͳ¿ª·¢³õÆÚ£¬ÓÉÓÚ¿ª·¢Êý¾Ý¿âÊý¾Ý±È½ÏÉÙ£¬¶ÔÓÚ²éѯSQLÓï¾ä£¬¸´ÔÓÊÓͼµÄµÄ±àдµÈÌå»á²»³öSQLÓï¾ä¸÷ÖÖд·¨µÄÐÔÄÜÓÅÁÓ£¬µ«ÊÇÈç¹û½«Ó¦ÓÃϵͳÌύʵ¼ÊÓ¦Óúó£¬Ëæ×ÅÊý¾Ý¿âÖÐÊý¾ÝµÄÔö¼Ó£¬ÏµÍ³µÄÏìÓ¦ËٶȾͳÉΪĿǰϵͳÐèÒª½â¾öµÄ×îÖ÷ÒªµÄÎÊÌâÖ®Ò»¡£ÏµÍ³ÓÅ»¯ÖÐÒ»¸öºÜÖØÒªµÄ·½ ......

aspÍøÒ³Àï,sql³£ÓòÙ×÷Óï¾ä!

Ìí¼Ó¡¢É¾³ý¡¢ÐÞ¸ÄʹÓÃ
db.Execute(Sql)ÃüÁîÖ´ÐвÙ×÷
╔----------------╗
¡î Êý¾Ý¼Ç¼ɸѡ ¡î
╚----------------╝
×¢Ò⣺µ¥Ë«ÒýºÅµÄÓ÷¨¿ÉÄÜÓÐÎó(ûÓвâʽ)
 
Sql = "Select
Distinct
×Ö¶ÎÃû from Êý¾Ý±í"
Distinctº¯Êý£¬²éѯÊý¾Ý¿â´æ±íÄÚ²»Öظ´µÄ¼Ç¼
 
......

sql ¿ç·þÎñÆ÷ ²éѯ

--´´½¨Á´½Ó·þÎñÆ÷
exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', 'Ô¶³Ì·þÎñÆ÷Ãû»òipµØÖ· '
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, 'Óû§Ãû ', 'ÃÜÂë '
--²éѯʾÀý
select * from ITSV.Êý¾Ý¿âÃû.dbo.±íÃû
--µ¼ÈëʾÀý
select * into ±í from ITSV.Êý¾Ý¿âÃû.dbo.±íÃû
--ÒÔºó²»Ô ......

SQL SERVER 2005Ⱥ¼¯


SQL SERVER 2005µÄȺ¼¯±ØÐëÔÚʵÏÖÁËWINDOWSȺ¼¯µÄ»ù´¡ÉϲſÉÒÔ¡£
Ê×ÏÈÎÒÃÇÏÈÀ´¿´Ò»ÏÂSQL SERVER 2005Ⱥ¼¯µÄһЩÏà¹Ø½éÉÜ£º
ÔÚSQL SERVER 2005ÖÐÖ÷Òª¿ÉÒÔʹÓþµÏñºÍȺ¼¯Á½ÖÖ·½·¨À´ÊµÏָ߿ÉÓÃÐÔ£¬ÖÁÓÚÊý¾Ý¿â¾µÏñ×÷ΪSQL SERVER 2005µÄÐÂÌØÐÔÖ®Ò»£¬ÎÒÔÚÇ°ÃæµÄ²©ÎÄÒѾ­×öÁ˽éÉÜ£¬½ñÌìÎÒÃǾÍÀ´¿´Ò»ÏÂȺ¼¯µÄÅäÖ÷½·¨£ºµ±È»Ëüà ......

sqlС±Ê¼Ç£¨5.26£©

sql server 2005 ¼òµ¥ÔËÓú¯Êý
1.null º¯Êý
  Ó÷¨ÓëoracleÖÐnvl()ÀàËÆ£¬´¦Àíº¯ÊýΪisnull()£¬
  ÀýÈ磺
    select ename,sal+isnull(comm,0)
    from emp
    go
  isnull(comm,0)µÄÓ÷¨ÊÇ£º commΪnull Ôò·µ»Ø0 ·ñÔòΪ commµÄÖµ¡£
2.V ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ