刚学数据库,求指导下面几个语句的含义,写上注释。谢谢了
if exists(select * from sysobjects where id=object_id(N'Test1') 
and OBJECTPROPERTY(id, N'IsUserTable') = 1)

解决方案 »

  1.   


    if exists(select * from sysobjects where id=object_id(N'Test1')  
    and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    --你这个不全,应该还有一句
    drop table Test1
    如果数据库中存在用户创建的表Test1就删除Test1
      

  2.   

    if exists(select * from sysobjects where id=object_id(N'Test1')  
    and OBJECTPROPERTY(id, N'IsUserTable') = 1)--表示在数据库中存在TEST1的表 IsUserTable=1表示这个表还是用户表,而不是系统表
      

  3.   

    查询当前数据库下,是否有一个叫"Test1"的用户表,如果有,此if条件则成立.
      

  4.   


    ---建表语句
    if object_id('Test1') is not null 
    drop table Test1
    go
    create table Test1(
     id int identity(1,1) primary key,
     startTime datetime,
     endTime datetime,
     人员 nvarchar(5))
      

  5.   

    if exists(select * from sysobjects where id=object_id(N'Test1')  
    and OBJECTPROPERTY(id, N'IsUserTable') = 1)exists是判断子查询是否返回记录子查中的select * from sysobjects where id=object_id(N'Test1')  
    and OBJECTPROPERTY(id, N'IsUserTable') = 1
    查找到id和表属性是用户表的记录