积极答复者
如何更有效率的判断一条记录是否存在?

问题
答案
-
或許你可以考慮用exists,例如下列的程式碼:
use Northwind go if exists (select * from Region where RegionID = '123') print 'exist' else print 'not exist'
以上說明若有錯誤請指教,謝謝。
http://www.dotblogs.com.tw/terrychuang/- 已编辑 TerryChuang 2012年3月6日 6:52
- 已建议为答案 Jacky_shen 2012年3月6日 9:04
- 已标记为答案 Molly Chen_Moderator 2012年3月13日 8:37
-
你也可以试用SELECT 1 FROM TableName WHERE ...
- 已建议为答案 Jacky_shen 2012年3月8日 11:53
- 已标记为答案 Molly Chen_Moderator 2012年3月13日 8:37
全部回复
-
或許你可以考慮用exists,例如下列的程式碼:
use Northwind go if exists (select * from Region where RegionID = '123') print 'exist' else print 'not exist'
以上說明若有錯誤請指教,謝謝。
http://www.dotblogs.com.tw/terrychuang/- 已编辑 TerryChuang 2012年3月6日 6:52
- 已建议为答案 Jacky_shen 2012年3月6日 9:04
- 已标记为答案 Molly Chen_Moderator 2012年3月13日 8:37
-
你也可以试用SELECT 1 FROM TableName WHERE ...
- 已建议为答案 Jacky_shen 2012年3月8日 11:53
- 已标记为答案 Molly Chen_Moderator 2012年3月13日 8:37