SQL Server CONVERT() º¯Êý
ÔÎijö´¦£ºhttp://www.dingos.cn/index.php?topic=1874.0
¶¨ÒåºÍÓ÷¨
CONVERT() º¯ÊýÊÇ°ÑÈÕÆÚת»»ÎªÐÂÊý¾ÝÀàÐ͵ÄͨÓú¯Êý¡£
CONVERT() º¯Êý¿ÉÒÔÓò»Í¬µÄ¸ñʽÏÔʾÈÕÆÚ/ʱ¼äÊý¾Ý
Óï·¨
CONVERT(data_type(length),data_to_be_converted,style)
data_type(length) ¹æ¶¨Ä¿±êÊý¾ÝÀàÐÍ£¨´øÓпÉÑ¡µÄ³¤¶È£©¡£data_to_be_converted º¬ÓÐÐèҪת»»µÄÖµ¡£style ¹æ¶¨ÈÕÆÚ/ʱ¼äµÄÊä³ö¸ñʽ¡£
¿ÉÒÔʹÓÃµÄ style Öµ£º
Style ID
Style ¸ñʽ
100 »òÕß 0
mon dd yyyy hh:miAM £¨»òÕß PM£©
101
mm/dd/yy
102
yy.mm.dd
103
dd/mm/yy
104
dd.mm.yy
105
dd-mm-yy
106
dd mon yy
107
Mon dd, yy
108
hh:mm:ss
109 »òÕß 9
mon dd yyyy hh:mi:ss:mmmAM£¨»òÕß PM£©
110
mm-dd-yy
111
yy/mm/dd
112
yymmdd
113 »òÕß 13
dd mon yyyy hh:mm:ss:mmm(24h)
114
hh:mi:ss:mmm(24h)
120 »òÕß 20
yyyy-mm-dd hh:mi:ss(24h)
121 »òÕß 21
yyyy-mm-dd hh:mi:ss.mmm(24h)
126
yyyy-mm-ddThh:mm:ss.mmm£¨Ã»Óпոñ£©
130
dd mon yyyy hh:mi:ss:mmmAM
131
dd/mm/yy hh:mi:ss:mmmAM
ʵÀý
ÏÂÃæµÄ½Å±¾Ê¹Óà CONVERT() º¯ÊýÀ´ÏÔʾ²»Í¬µÄ¸ñʽ¡£ÎÒÃǽ«Ê¹Óà GETDATE() º¯ÊýÀ´»ñµÃµ±Ç°µÄÈÕÆÚ/ʱ¼ä£º
view plaincopy to clipboardprint?
CONVERT(VARCHAR(19),GETDATE())
CONVERT(VARCHAR(10),GETDATE(),110)
CONVERT(VARCHAR(11),GETDATE(),106)
CONVERT(VARCHAR(24),GETDATE(),113)
½á¹ûÀàËÆ£º
Dec 29 2008 11:45 PM
12-29-2008
29 Dec 08
29 Dec 2008 16:25:46.635
Ïà¹ØÎĵµ£º
ORMϵͳ±ØÐë°ÑÊý¾Ý¿âÖеÄÊý¾Ýת»»ÎªÒµÎñÊý¾Ý£¬×ª»»µÄ·½·¨´óÖÂÓÐ3ÖÖ£¬±¾ÎľÍÊÔͼ¶ÔËüÃÇ×öһЩ¼òµ¥·ÖÎö¡£
1¡¢ÊôÐÔ·´Éä¡£¾ÍÊÇͨ¹ý·´É䣬»ñÈ¡ÒµÎñʵÌåÀàµÄ¸÷¸öÊôÐÔ£¬È»ºóÔÙÉèÖÃÕâЩÊôÐÔµÄÖµ¡£Õâ¸ö·½·¨×î¼òµ¥¡¢×îÎȶ¨¡¢Í¨ÓÃÐÔ×îÇ¿¡¢¿Éά»¤ÐÔ×îÇ¿¡¢ÐÔÄÜ×î²î¡£ÀýÈçNHibernate¾ÍÊÇÓÃÕâÖÖ·½·¨ÊµÏֵģ¬Ëüͨ¹ýIGetterºÍISetter½Ó¿ÚÊµÏ ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Collections;
using System.Data.SqlClient;
/// <summary>
/// Êý¾Ý¿âµÄͨÓ÷ÃÎÊ´úÂë
/// ´ËÀàΪ³éÏóÀ࣬²»ÔÊÐíʵÀý»¯£¬ÔÚÓ¦ÓÃʱֱ½Óµ÷Óü´¿É
/// </summary>
public ab ......
ʹÓÃHIBERNATEµÄSQL²éѯ²¢½«½á¹û¼¯×Ô¶¯×ª»»³ÉPOJO
ÎÄÕ·ÖÀà:Java±à³Ì
ÔÚijЩ³¡ºÏÏ£¬ÎÒÃÇ¿ÉÄÜÏëʹÓÃHIBERNATEµÄ¿ò¼ÜÌṩµÄSQL²éѯ½Ó¿Ú£¬Õâʱ£¬ÓÉÓÚ±íºÍʵÌ嶼¿ÉÄÜûÓÐ×öÓ³É䣬HIBERNATE²»Äܰѽá¹û¼¯×ª»»
³ÉÄãÏëÒªµÄList<POJO>£¬±¾ÎÄÌÖÂÛÈçºÎÔÚÕâÖÖÇé¿öÏÂÈÃHIBERNATEÖ±½Ó·µ»ØÄãÏëµÄ½ ......
¹úÍâ¿Õ¼äòËƶÔÖÐÎıȽϸÐð Èç¹ûÊý¾ÝÀàÐÍÉè¼ÆΪ varchar ÀàÐ͵Ļ° ´æ´¢µÄÊý¾Ý»ù±¾ÉÏÊÇ "£¿£¿£¿£¿"
ºÜ¼òµ¥ ½« varchar ÀàÐÍ Éè¼ÆΪ nvarchar ÀàÐÍ
create table cs
(
txt1 nvarchar(50) null
)
insert into cs (txt1 ) values ('²âÊÔ') -- Èë¿âʱÊý¾Ýʱ £¿£¿£¿£¿
insert into cs (txt ......
1.°´ÐÕÊϱʻÅÅÐò: Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ: select encrypt('ÔʼÃÜÂë') select pwdencrypt('ÔʼÃÜÂë') select pwdcompare('ÔʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ
3.È¡»Ø±íÖÐ×Ö¶Î: declare @list varchar(1000),@sql nvarchar(1000)&n ......