Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the table name in visual studio 2013 in design mode?

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?

enter image description here

like image 555
Samiey Mehdi Avatar asked Dec 12 '13 08:12

Samiey Mehdi


People also ask

How do I rename a table in Visual Studio?

In Object Explorer, right-click the table you want to rename and choose Design from the shortcut menu. From the View menu, choose Properties. In the field for the Name value in the Properties window, type a new name for the table.

How do you create a table in Visual Studio?

Right-click on Tables and select Add New Table. The Table Designer opens and shows a grid with one default row, which represents a single column in the table that you're creating. By adding rows to the grid, you'll add columns in the table. Right-click on the CustomerID row, and then select Set Primary Key.

How do I show tables in Visual Studio?

It's just right click on the table in your Database Schema in Server Explorer then choose Show Table Data.


4 Answers

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.

enter image description here

like image 80
Samiey Mehdi Avatar answered Oct 28 '22 09:10

Samiey Mehdi


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

like image 40
Sel Avatar answered Oct 28 '22 07:10

Sel


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:

enter image description here

like image 35
Shahram fr Avatar answered Oct 28 '22 08:10

Shahram fr


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:

  1. rename [dbo][Table] to [dbo][yourTable]
  2. press update button
  3. Refresh a few times, it may take a minute.

Hope this helps :) It seems a like really wierd bug.

like image 27
F. Hamers Avatar answered Oct 28 '22 07:10

F. Hamers