SQLʱ¼äÀàÐÍÄ£ºý²éѯ
Êý¾Ý¿âÀàÐÍΪDateTimeÀàÐÍ£¬½«Æä×öÄ£ºý²éѯʱ£¬ÔÚHibernateÖУ¬¿ÉÒÔÓÃÆ´SQLµÄÎÊÌ⽫Æä½â¾ö£¬¼´ÔÚSQL²éѯ·ÖÎöÆ÷дSQLÒ»Ñù£¬µ«ÊÇÀûÓòÎÊýÅäÖã¬Ôò·½·¨ÈçÏ£º
1¡¢Æ´ÉÏSQL,È磺
String beginPara= " and b.date>= :begin";
String endPara= " and b.date<= :end";
2¡¢hqlÓï¾ä½øÐвÎÊýÅäÖá£È磺
queryString.append(beginPara);
queryString.append(endPara);
3¡¢½øÐвÎÊýÉèÖã¬Èç
q.setString("begin", date+" 00:00:00");
q.setString("end", date+" 23:59:59");
ÒÔÉÏÔòÊDzéÒ»ÌìµÄʱ¼äÀàÐÍÊý¾Ý
Ïà¹ØÎĵµ£º
SELECT CONVERT(varchar(100), CAST(@testFloat AS decimal(38,2)))
SELECT STR(@testFloat, 38, 2)
´ÓExcelÖе¼Èëµ½sql2000£¬ÓÐÒ»ÁГÁªÏµ·½Ê½”±ä³ÉÁËfloatÀàÐÍ£¬ÎÒÏëת»»³ÉnvarcharÀàÐÍ£¬ÓÃÏÂÃæµÄÓï¾ä
select convert(nvarchar(30),convert(int,ÁªÏµ·½Ê½)) from employee
go
//Êý¾ÝÒç³ö£¬²»ÐУ¡
select ......
Ò».Êý¾Ý¿ØÖÆÓï¾ä (DML) ²¿·Ö
1.Insert (ÍùÊý¾Ý±íÀï²åÈë¼Ç¼µÄÓï¾ä)
Insert INTO ±íÃû(×Ö¶ÎÃû1, ×Ö¶ÎÃû2, ……) VALUES ( Öµ1, Öµ2, ……);
&nb ......
Ò».Îı¾µ¼ÈëÊý¾Ý¿â
--²½Öè1.´´½¨¿ØÖÆÎļþ
load data¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ --1¡¢¿ØÖÆÎļþ±êʶ
infile 'E:\oradata\orcl\test\inf_user.txt'¡¡¡¡¡¡¡¡¡¡¡¡¡¡ --2¡¢ÒªÊäÈëµÄÊý¾ÝÎļþÃûΪinf_user.txt (Îļþȱʡ·Åµ½C:\ Ï£¬Èç¹û²»ÊÇ£¬¾ÍÐèÒªÖ¸Ã÷ȫ·¾¶)
append into table inf_user¡¡¡¡¡¡¡¡--3¡¢Ïò±ítestÖÐ× ......
using System;
using System.Data;
using System.Configuration;
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.SqlClient;
using AHUT_TetWebERP;
......
http://xujunprogrammer.blog.hexun.com/8376520_d.html
SQL ServerÖÐÎİæµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
Õâ¶ÔÓÚÔÚÒª²»Í¬Êý¾Ý¿â¼ä×ªÒÆÊý¾Ý»òÕßϰ¹ßoracleÈÕÆÚ¸ñʽYYYY-MM-DD HH24:MI:SSµÄÈ˶àÉÙÓÐЩ²»·½±ã.
ÎÒÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄ ......