===============怎样判断删除表是否成功===========

zhangjjhua 2007-08-11 12:18:07
1.怎样判断数据库中删除(整个表)表是否成功,用什么返回值,int 好象不行,


2.删除成功之后,怎样在页面(C#中)判断数据库中是否存在该表(table1)

select name from sysobjects where name='table1' and type='u'


怎样得到这个select 查询的结果()


...全文
253 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Limpire 2007-08-11
  • 打赏
  • 举报
回复
if object_id(name) is null
begin
--delete succeed
--not exists table1
end
else
begin
--delete failed
--exists table1
end
fa_ge 2007-08-11
  • 打赏
  • 举报
回复
1.怎样判断数据库中删除(整个表)表是否成功,用什么返回值,int 好象不行,

---------
select * from sysobjects where xtype='U' and name='aaa'
select @@rowcount

0:不存在
1: 存在

2.删除成功之后,怎样在页面(C#中)判断数据库中是否存在该表(table1)


-------------

if exists(select 1 from sysobjects where xtype='U' and name='aa')
begin


end
zhangjjhua 2007-08-11
  • 打赏
  • 举报
回复
谢谢,问题解决!
明天就可以交差了,啊,谢谢各位大哥!(可能有大姐的!)
zhangjjhua 2007-08-11
  • 打赏
  • 举报
回复
谢了,各位,我试一下各位的方法,稍后分就到,稍等片刻!
片刻!

hb_gx 2007-08-11
  • 打赏
  • 举报
回复
怎样判断数据库中删除(整个表)表是否成功?删除表的的DDL语法,要么成功,要么报错,报错了肯定是没成功了,这个跟本不用接返回值


在页面(C#中)判断数据库中是否存在该表

SqlCommand cmd = new SqlCommand("select * from sysobjects where xtype='U' and name='"+ 表名 +"',cnn)

SqlDataReader dr = cmd.ExecuteReader()

if (dr.Read())
{
//如能进来,表肯定还在没有删除
}

27,582

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧