I created a SQL database table in Visual Studio 2013. I want to rename it but the name property is disabled. How can I change the table name?
In Server Explorer right click on Views and click New Query.
use this code to rename table:
EXEC sp_rename 'Table', 'NewName'
then click on Execute button.
after 5-30 seconds in server explorer click on refresh button.
You can change table name in SQL Server Object Explorer in Visual Studio. Choose the table in tree and rename by right-click on the table -> rename
The correct answer as follows: 1.First select your table that you want to change. 2. Then change the name in the script pane. 3.Finally in the upper-left corner of the Table Designer, choose the Update button. Please as shown below:
Ive been trying to too, and the simple option to rename the [dbo][Table] did not seem to work.
But it actually does! Please note that refreshing doesn't work right away.
Steps:
- rename [dbo][Table] to [dbo][yourTable]
- press update button
- Refresh a few times, it may take a minute.
Hope this helps :) It seems a like really wierd bug.
You can change table name in T-SQL part as showin in image as follows..
CREATE TABLE{dbo].[t1]{
{
...
...
}
to
CREATE TABLE{dbo].[t2]{
{
...
...
}
ans then press "Update" button present above...
As explained here, found through "visual studio server explorer rename table", you can't.
There is a workaround: add the tables to a database diagram, rename it there and save it.
(using VS2013) I came looking on here because I had written the main table for my project this afternoon, and as usual set it's name in T-SQL. But had not realized that the name had not stuck until I went to use it in the Linq-to-SQL I tried over and over to rename it, and I had refreshed many times.
The default name 'Table', has an obvious clash problem in normal code.
Then tonight came on here to see if you guys had found a way and opened the project to try some out.
Turns out that although the original table called 'Table' was still there, I now had many copies of it, one for each attempt at renaming it.
So I think from that we can assume the table renaming problem is a bug rather than a feature, and that MS use a copy first, then should do the deete of the file that is being renamed. But also that the refresh does not work on these copies until the project is closed and then reopened. Yes I know, a bit cheesey, but at least there is a way around.
Personally, with this and the database overwrites at run time, I am starting to lean towards letting the database designer create the scripts for my program to use rather than creating the tables and other database parts. That puts everything back into your hands, which must be a good thing.
I haven't quite got to grips with doing the Linq-to-SQL manually yet, and it is such a bonus to a programmer that I have to tackle that first.
This will help if you accidently put a dang period in your table name
EXEC sp_rename '[dbo].[Vb.Net]','VB'
Just rename the [dbo][Table] to [dbo][TableName] press the update button.
© 2022 - 2024 — McMap. All rights reserved.