SQL修改表名称

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,N'IsUserTable')=1)exec sp_rename 'Liver_Items_Parts' ,'Old_Liver_Items_Parts';

 

posted @ 2012-06-04 13:40  chend926  阅读(223)  评论(0)    收藏  举报