以文本方式查看主题 - 昂捷论坛 (http://enjoyit.com.cn/bbs/index.asp) -- □-技术研讨会 (http://enjoyit.com.cn/bbs/list.asp?boardid=36) ---- 纠正一个容易产生的sql错误认识 (http://enjoyit.com.cn/bbs/dispbbs.asp?boardid=36&id=2148) |
-- 作者:飞絮 -- 发布时间:2006/9/25 17:06:17 -- 纠正一个容易产生的sql错误认识
select @sort_id=10 select @sort_id=20 from sysobjects where 1=2 select @sort_id 你认为@sort_id是多少? 是 10,20 还是 NULL |
-- 作者:飞絮 -- 发布时间:2006/9/25 18:04:54 -- 对,不是null,那么以下程序就隐含了错误: select top 1 @sort_id=c_sort from tb_o_wg (nolock) where c_id=@id and c_adno=@adno select top 1 @sort_id=c_sort from tb_o_wg (nolock) where c_id=@id and isnull(c_pt_cost,0)=0 应注意避免这种隐藏较深的逻辑错误 |
-- 作者:boom -- 发布时间:2006/10/10 9:39:20 -- 顶一下 |