Click here to Skip to main content
15,887,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I try to rename table name which contain "." using sp_rename in sql server,

E.g:
JavaScript
sp_rename N'1043_MMM.LKJ', N'1043_MMMLKJ'



i will get error like this

C#
Msg 15225, Level 11, State 1, Procedure sp_rename, Line 374
No item by the name of '[1043_MMM.LKJ]' could be found in the current database 'master', given that @itemtype was input as '(null)'.


How to solve this ?

I cant Drop and create table again,bcz it contains value,so i want rename only.
Any special character got restriction for creating table in sql server ? if got pls give information.

Manually can rename table

Regards
Aravind

What I have tried:

if i run in master database in sql server also same error.
Posted
Updated 3-Feb-21 4:09am
Comments
Richard Deeming 20-Dec-16 10:31am    
Why are you creating user tables in the master database?

And if it's not in the master database, why are you running your sp_rename script from the wrong database?
Aravindba 21-Dec-16 1:37am    
Thank u ur reply,Actually above script working without dot in table name,i am passing that script in command text and that command text connection is local database,not master table.if i run in sql directly without dot it working.

You can also place brackets around the string, as shown here:
SQL
EXEC sp_rename N'[1043_MMM.LKJ]', N'1043_MMMLKJ'
 
Share this answer
 
If your table name contains identifier, and if you want to rename it, you should run wrap the tablename with double quotes (“) and use the sp_rename command.

Try this:

sp_rename N'"1043_MMM.LKJ"', N'1043_MMMLKJ'
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900