摘要: 在SQL中判断一个表是否存在 <%sql="if exists (select * from sysobjects where id = object_id(N'[dbo].[phone]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[phone]" con.execute(sql) %> 如果表phone存在则删除phone表,其中phone是表名,con是connection对像 两个假设: 1、已知数据库中所有的表默认的 Owner,如dbo( 阅读全文
posted @ 2012-06-04 13:51 chend926 阅读(193) 评论(0) 推荐(0) 编辑
摘要: sp_rename [ @objname = ] 'object_name' , [ @newname = ] 'new_name' [ , [ @objtype = ] 'object_type' ] 用法,如果数据库中存在Liver_Items_Parts表,将它重新命名为Old_Liver_Items_Parts]if exists(select * from sysobjects where id = OBJECT_ID(N'[dbo].[Liver_Items_Parts]')and OBJECTPROPERTY(id, 阅读全文
posted @ 2012-06-04 13:40 chend926 阅读(219) 评论(0) 推荐(0) 编辑