易截截图软件、单文件、免安装、纯绿色、仅160KB

关于时间段的SQL(Orcale、SQL Server)查询

一、Orcale 时的查询
String hql = "from SmsTemplate t where 1=1 ";
 if (model != null && !"".equals(model.getEndTimes())&& null!=model.getEndTimes() ) {
   SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd"); //格式化当前系统日期
   Date endt = model.getEndTimes();
   String dateTime = dateFm.format(endt);
   
   hql += " and t.endTimes<= to_date('" + dateTime+"' ,'yyyy-mm-dd')"; //注意单引号
   //hql += " and t.endTimes<= to_date('" + dateTime+"' ,'yyyy-mm-dd HH24:mi:ss')";//带时、分、秒 注意 mi
//注:endTimes在数据库中时DATE型的
  }
二、普通SQL Server 查询
DECLARE @dt DATETIME
DECLARE @dt2 DATETIME
SET @dt = '2008-07-24'
SET @dt2 = DATEADD(day, 1, @dt)
select @dt as dt, @dt2 as dt2
select * from meet_now where meetdate between CONVERT(datetime , @dt, 111 ) and convert(datetime , @dt2, 111 ) order by id
select * from meet_now where DATEDIFF(day, meetdate, @dt) = 0 order by id


相关文档:

SQL*Plus FAQ

 What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server software. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers ......

SQL SERVER中全文检索的创建与应用

      全文搜索的核心引擎建立在Microsoft Full-Text Engine for SQL Server (MSFTESQL) 服务提供支持
      面对海量的数据,如何才能找到我需要的?对数百万行文本数据执行的LIKE 查询可能需要花费几分钟时间才能返回结果;但对同样的数据,全文查询只需要几秒或更少 ......

Sql Server 获得各种形式的日期

SQL codeDECLARE @dt datetime
SET @dt=GETDATE()
DECLARE @number int
SET @number=3
--1.指定日期该年的第一天或最后一天
--A. 年的第一天
SELECT CONVERT(char(5),@dt,120)+'1-1'
--B. 年的最后一天
SELECT CONVERT(char(5),@dt,120)+'12-31'
--2.指定日期所在季度的第一天或最后一天
--A. 季度的第一天
SE ......

常用 SQL 语句大全

本文总结了开发工作中常用的SQL语句,供大家参考……
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
A ......

批处理bat执行sql脚本

set r=%time%
echo %r%开始导入 >>e:\c#\test.txt
osql -S (local) -U sa -P -d colorring -i e:\c#\11.sql >>d:\c#\test.txt
echo %r%导入完成 >>e:\c#\test.txt
其中11.sql中为
bulk insert  colorring..test from 'e:\c#\11.txt'
WITH (
FIELDTERMINATOR = ',',
ROWTERMINATOR ='\n' ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号