你参数用错了if object_id('tb') is not null drop table tb go create table tb ( id int, name varchar(10) ) go exec sp_rename 'tb.name','name1' select * from tb /* 注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。 id name1 ----------- ----------(0 行受影响) */
create table abc(id int,country varchar(20),delta varchar(20),[found]]] datetime) insert into abc select 1,'aa','bb',GETDATE() select * from abc /* id country delta found] ----------- -------------------- -------------------- ----------------------- 1 aa bb 2011-12-13 22:40:33.893(1 行受影响)*/ go exec sp_rename 'abc.[found]]]','found','column' /* 注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。 */go select * from abc /* id country delta found ----------- -------------------- -------------------- ----------------------- 1 aa bb 2011-12-13 22:40:33.893(1 行受影响) */ go drop table abc
drop table tb
go
create table tb
(
id int,
name varchar(10)
)
go
exec sp_rename 'tb.name','name1'
select * from tb
/*
注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。
id name1
----------- ----------(0 行受影响)
*/
exec sp_rename 'abc.found]','found','column'
消息 15253,级别 11,状态 1,过程 sp_rename,第 105 行
分析 SQL 标识符 'abc.found]' 时出现语法错误。
是这个问题
insert into abc select 1,'aa','bb',GETDATE()
select * from abc
/*
id country delta found]
----------- -------------------- -------------------- -----------------------
1 aa bb 2011-12-13 22:40:33.893(1 行受影响)*/
go
exec sp_rename 'abc.[found]]]','found','column'
/*
注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。
*/go
select * from abc
/*
id country delta found
----------- -------------------- -------------------- -----------------------
1 aa bb 2011-12-13 22:40:33.893(1 行受影响)
*/
go
drop table abc