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

SQL SERVER中一些特别地方的特别解法

SQL code
/*----------------------------------------------------------------
-- Author :feixianxxx(poofly)
-- Date :2010-04-20 20:10:41
-- Version:
-- Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
Mar 29 2009 10:27:29
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 6.1 <X86> (Build 7600: )
-- CONTENT:SQL SERVER中一些特别地方的特别解法2
----------------------------------------------------------------*/
--1.关于where筛选器中出现指定星期几的求解
SQL code
--环境
create table test_1
(
id int,
value varchar(10),
t_time datetime
)
insert test_1
select 1,'a','2009-04-19' union
select 2,'b','2009-04-20' union
select 3,'c','2009-04-21' union
select 4,'d','2009-04-22' union
select 5,'e','2009-04-23' union
select 6,'f','2009-04-24' union
select 7,'g','2009-04-25'
go
我们一般通过 datepart(weekday )进行求解,比如求解星期2的记录
select * from test_1
where DATEPART(WEEKDAY,t_time+@@DATEFIRST-1)=2
/*
id value t_time
----------- ---------- -----------------------
3 c 2009-04-21 00:00:00.000
*/
这里涉及到 @@datefirst 这个系统变量,一般我们用来调节不同地方的日期习惯。
如果你觉得关于这个变量很难也懒得去依赖它调节,这里还有一种方法
你可以使用一个参照日期,通过相同星期数成7的倍数的原理进行查询
select * from test_1
where DATEDIFF(DAY,'1900-01-02',t_time)%7=0
/*
id value t_time
----------- ---------- -----------------------
3 c 2009-04-21 00:00:00.000
*/
--2.关于在where筛选器中指定大小写查找的索引引用问题
SQL code
--环境
--drop table test_2
create table test_2
(
id int identity(1,1),
value varchar(10)
)
insert test_2 select
'abc' union all select
'Abc' union all select
'ABC' union all select
'aBc'
go
create clustered index in_value on test_2(value)
--我先要查找 值为'ABC'的记录 要区分大小写的
select * from test_2
where value COLL


相关文档:

SQL Server选择了非聚集索引而不是聚集索引

聚集索引不仅包含索引的key值,还包含表数据;
非聚集索引只包含索引的key值。
SQL Server在有些情况下,有聚集索引和非聚集索引存在时,会选择走非聚集索引,而不走聚集索引。
例子如下:
在 SQL Server 的adventureWorks数据库下,运行如下语句:
select DepartmentID,Name from HumanResources.Department
Departm ......

用sql操作oracle的blob字段

用sql操作oracle的blob字段
1、查询
select utl_raw.cast_to_varchar2(dlob),id from system.t_htinfo 
2、插入
insert into system.t_htinfo  values ('3',utl_raw.cast_to_raw('你'));
3、更新
update system.t_htinfo set fld_value=utl_raw.cast_to_raw('1') where fh_nm=1820648 and form_index=52
......

sql server 日志文件的收缩

完全备份或日志备份虽说都有截断日志的功能,但是不会收缩日志文件的空间返回给操作系统.
如果你想将日志文件的空间返回给操作系统的话,只有一种方法,就是收缩数据库(选择日志文件)
ZT一个相关帖子,供参考!
物理日志文件:
    这个比较好理解,实实在在的东西,数据库目录下面的.ldf文件就是,有些人喜欢改后 ......

SQL Server 2000 重命名数据库

某项目之前的数据库有变化,但是以前写的程序是支持老数据库的,新数据库有一些问题,需要修改,但是数据库就重复了,于是就要把开发机上之前的数据库重新命名。
这里记录一下步骤(旧名称:MobileMsg,新名称:MobileMsg_old):
1、关掉企业管理器,打开查询分析器;
2、修改数据库名称:
EXEC sp_dboption 'MobileMs ......

JAVA连接sql server 2005 数据库心得

首先得下载驱动程序到微软网站下载Microsoft SQL Server 2005 JDBC Driver 1.2
解压Microsoft SQL Server 2005 jdbc driver1.2.exe,把sqljdbc_1.1复制到%ProgramFiles%(如果系统在C盘则为C:\Program Files)。
设置 Classpath
JDBC 驱动程序并未包含在 Java SDK 中。因此,如果要使用该驱动程序,必须将 classpath ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号