首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

object_id与select * from dbo.sysobjects where id = object_id的差异

2012-09-03 
object_id与select * from dbo.sysobjects where id object_id的区别SQL codeif exists (select * from

object_id与select * from dbo.sysobjects where id = object_id的区别

SQL code
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_test]'))begin   select 1end if object_id(N'[dbo].[fn_test]') is  not  nullbegin   select 2end 

请问这个2句sql语句(object_id)和 (select * from dbo.sysobjects where id = object_id(。。。))这个有区别吗

[解决办法]
判断的时候最好加一个type的限定,指定对象是表 函数 存储过程等,如果有相同名字,例如有fn_test的表及存储过程,那么这个判断不是很准确。

热点排行