惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
量子位
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
IT之家
IT之家
V
Visual Studio Blog
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
D
Docker
V
V2EX

博客园 - gz.net

gridview绑定问题 - gz.net - 博客园 好久没来了。共享一个自动生成编号的存储过程 jsp数据库大全 login Microsoft Windows SharePoint Services ASP.NET程序中常用代码汇总(一) - gz.net - 博客园 ASP.NET动态生成HTML页面 日语的初次认识 日语的初次认识 对于长时间装载的ASP.NET页面如何在客户端浏览器中显示进度? 检测远程URL是否存在的三种方法 ---转自孟子 Eclipse快速上手指南 自己动手用c#写控件 代价 五种提高 SQL 性能的方法 js教程 HTML教程 HTML教程 存储过程经验二
存储过程编写经验三
gz.net · 2004-09-06 · via 博客园 - gz.net

1.       了解表的连接原理,能力进阶的关键

1)  灵活性,左连接,右连接。。。

2)  查询效率,条件语句的写法和顺序,自己掌握优化的主动权。

3)  保证正确,如update from累加修改时

       update tMembers

                     set

                            iShareA  = a.iShareA + b.iNewShare

                     from vMembers a, (select * from vMembers) b

                     where a.iMemberID = b.iUpMemberID

       update tMembers

                     set

                            iShareA  = a.iShareA + b.iNewShare

                     from tMembers a, (select * from vMembers) b

                     where a.iMemberID = b.iUpMemberID

区别:

使用视图时,左侧iShareA 右侧a.iShareA不是同一条记录;使用表时是一条。

iShareA  = a.iShareA + b.iNewShare

2.       一些经验

2.1     善用临时表

1)避免多用户重名冲突。

2)  速度快,内存表。

3)  简化逻辑

4)  数据重用

2.2     回避not in 的技巧

  --打标记bMark = 1(下一步对bMark = 0 的进行插入,这样速度快得多)

  update #tWIV_Total set bMark = 1

  from

    #tWIV_Total a, tTWAccount b

  where

    a.cWhsID = b.cWhsID  and a.cItemID = b.cItemID and a.cVendorID = b.cVendorID

  -- 3)bMark = 0 的关键字插入到tTWAccount

  insert into tTWAccount (cWhsID, cItemID, cVendorID, cCtrGrpID) 

  select

    cWhsID,

    cItemID,

    cVendorID,

    '' -- because not null

  from

    #tWIV_Total

  where

    bMark = 0

2.3     浮点数慎用

1)  会有芯片运算影响等问题

2)  累计求和时,舍入误差,经常产生“1分钱问题”。

3)  运行中产生意外结果,如判断 = 0,本来是0,可能判断结果不为0

2.4     统计数字作分母时,注意筛选条件加上<> 0限制,如

                     select iLevel, count(*) iCount

                            into #tChainLevelCount

                            from tMembers a, tChainLevel b

                            where

                                   a.iLevel = b.iID

                                   and a.cState = '0' and b.cType = 'A'

                            group by iLevel

                            having count(*) > 0