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

sql 2005 强制使用执行计划 T—SQl

select * from tt t inner loop join ss s with(nolock) on s.c=t.c
 
 使用 nested join
select * from tt t inner merge join ss s with(nolock) on s.c=t.c
 
 使用 merge join
 
select * from tt t inner hash join ss s with(nolock) on s.c=t.c
 
使用  hash jion
 
nolock 不允许锁 
 
 
 
 
Microsoft SQL Server sometimes uses hash and merge joins when querying large tables when uncomplicated nested loop joins would result in better performance and less server impact. In many such cases, query times go from many milliseconds to many seconds because hash table joins require that large amounts of data be processed and temporarily stored, and merge joins require sorting and then processing similarly large amounts of data.
This is fine for one-time administrative "fact finding" queries where you don't have or want the indices needed to optimize the query, and you're willing to wait the seconds or minutes it takes to get results.
For day-in-and-day-out application queries, however, you don't want your database engine to be hashing or sorting hundreds of thousands or millions of rows, especially when the end result is only a small number of rows.


相关文档:

SQL函数 left()、charindex()的使用

SQL函数 left()、charindex()的使用
1、left()
LEFT (<character_expression>, <integer_expression>)
返回character_expression 左起 integer_expression 个字符。
2.charindex()
返回字符串中某个指定的子串出现的开始位置。
CHARINDEX (<’substring_expression’>, <expressio ......

SQL函数:事务实例 伟少天地

事务就是负责把一系列操作看做一个独立的逻辑单元,这些操作要么同时成功,要么同时失败。下面是一个经典的例子:
create procedure TransferMoeny
(
    @fromAccountNo varchar(50),-- 转出账号
    @ToAccountNo varchar(50),--转入账号
 & ......

SQL快速用启动


开启各种服务
      @NET stop SQLSERVERAGENT
      @NET stop MSSQLServerOLAPService
      @NET stop msftesql
      @NET stop MsDtsServer
      @NET stop SQLWriter
  ......

select * into 和insert into SQL SERVER

select * into destTbl from srcTbl
insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl
以上两句都是将 srcTbl 的数据插入到 destTbl,但两句又有区别的:
第一句(select into from)要求目标表(destTbl)不存在,因为在插入时会自动创建。
第二句(insert into select from)要求目标表(dest ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号