--语法没有问题
exec sp_rename '旧表名','新表名'

解决方案 »

  1.   

    應該沒問題吧。A. 重新命名資料表
    本範例將 customers 資料表重新命名為 custs。EXEC sp_rename 'customers', 'custs'
      

  2.   

    如果是重命名数据库,用:sp_renamedb
    更改数据库的名称。
      

  3.   

    select * into b from a
    drop table a
      

  4.   

    create table test(
    id int identity,
    F1 varchar(50)
    )
    go
    insert test
    select 'aa'  union all 
    select 'bb'exec sp_rename 'test','test1'
    --上面这个执行成功。create table #test(
    id int identity,
    F1 varchar(50)
    )
    go
    insert #test
    select 'aa'  union all 
    select 'bb'exec sp_rename '#test','test2'--报错信息如下!
    服务器: 消息 15225,级别 11,状态 1,过程 sp_rename,行 273
    未能找到名为 '#test' 的项(在当前数据库 'mystudy' 中,假定输入的 @itemtype 为 '(null)')。晕了,这是怎么回事?我数据库中确实没有test2
    select * from #test
      

  5.   

    臨時表是存儲在tempdb這個數據庫中的。
      

  6.   

    谢谢paoluo(一天到晚游泳的鱼) :)也谢谢楼主的帖,让我又学了东西。