SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
¡¾ÎÊÌâÃèÊö£º¡¿
Ò»¸öÓû§±íÖеÄ×¢²áÈÕÆÚÏÔʾ¸ñʽÊÇ£ºyyyy-mm-dd Thh:mm:ss.mmm ¡£¶øÎÒÏëͳ¼Æ³öÿÌìµÄÓû§×¢²áÊý£¬Ö±½Ógroup×¢²áÈÕÆÚ×Ö¶ÎÏÔÈ»ÊDz»Ðеġ£
¡¾ÎÊÌâ´¦Àí£º¡¿
ÀûÓÃSQLserverÖеÄconvertº¯Êý¶ÔÈÕÆÚ½øÐÐת»»×ª»»¡£groupת»»ºóµÄÈÕÆÚ¡£
¡¾½Å ±¾£º¡¿
--²éѯij¸öÔÂÿÌìµÄÓû§×¢²áÊý
use USERDB
select count(*) as total,convert(varchar(12),RegisterDateTime,106) as date from DB.USERNAME
where RegisterDateTime between '2009-11-01' and '2009-11-30'
group by convert(varchar(12),RegisterDateTime,106)
×¢£ºuserdbΪ¿â£¬db.usernameΪ±í
¡¾Ïà¹Ø֪ʶ£º¡¿
SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ2008-01-15 15:51SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
SQL ServerÖÐÎÄ°æµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
ÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄܾ³£»áÓõ½µÄÈÕÆÚ¸ñʽת»»·½·¨:
¾ÙÀýÈçÏÂ:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004
select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004
select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004
select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004
select CONVERT(varchar(12) , getdate(), 108 )
11:06:08
select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1
select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004
select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1
select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
select getdate()
½á¹û£º2003-12-28 16:52:00.107
select con
Ïà¹ØÎĵµ£º
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlC ......
if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE FUNCTION SplitStr (@splitString varchar(8000), @separate varchar(10))
RETURNS @returnTable ......
²éѯnorthwindÊý¾Ý¿âÖÐordersÖеÄ10µ½20Ìõ¼Ç¼
select top 10 * from orders
where orderid > ( select max(orderid) from (select top 10 orderid from orders order by orderid) as t&nbs ......
BULK INSERT
¡¡¡¡ÔÚSQL ServerÖУ¬BULK INSERTÊÇÓÃÀ´½«ÍⲿÎļþÒÔÒ»ÖÖÌض¨µÄ¸ñʽ¼ÓÔص½Êý¾Ý¿â±íµÄT-SQLÃüÁî¡£¸ÃÃüÁîʹ¿ª·¢ÈËÔ±Äܹ»Ö±½Ó½«Êý¾Ý¼ÓÔص½Êý¾Ý¿â±íÖУ¬¶ø²»ÐèҪʹÓÃÀàËÆÓÚIntegration ServicesÕâÑùµÄÍⲿ³ÌÐò¡£ËäÈ»BULK INSERT²»ÔÊÐí°üº¬Èκθ´ÔÓµÄÂß¼»òת»»£¬µ«Äܹ»ÌṩÓë¸ñʽ»¯Ïà¹Øµ ......
SQL Serverµ¼³ö±íµ½EXCELÎļþµÄ´æ´¢¹ý³Ì:
¡¡¡¡*--Êý¾Ýµ¼³öEXCEL
¡¡¡¡µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþΪÕæÕýµÄExcelÎļþ
¡¡¡¡,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
¡¡¡¡,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
¡¡¡¡»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
¡¡¡¡---*/
¡¡¡¡/**//*--µ÷ÓÃʾÀý
¡¡¡¡p_exporttb @tbname='µØÇø ......