以文本方式查看主題 - 昂捷論壇 (http://www.yzsenyi.com/bbs/index.asp) -- □-技術研討會 (http://www.yzsenyi.com/bbs/list.asp?boardid=36) ---- 糾正一個容易產(chǎn)生的sql錯誤認識 (http://www.yzsenyi.com/bbs/dispbbs.asp?boardid=36&id=2148) |
-- 作者:飛絮 -- 發(fā)布時間:2006/9/25 17:06:17 -- 糾正一個容易產(chǎn)生的sql錯誤認識
select @sort_id=10 select @sort_id=20 from sysobjects where 1=2 select @sort_id 你認為@sort_id是多少? 是 10,20 還是 NULL |
-- 作者:飛絮 -- 發(fā)布時間: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 -- 發(fā)布時間:2006/10/10 9:39:20 -- 頂一下 |