问题
I have SQL Server 2012 Management Studio. I am trying to create tables using commands.
After creating the table, I try to use the DESC
command to view the table structure but it shows error saying
incorrect syntax near the keyword 'DESC'.
The statement is:
DESC doughnut_list;
回答1:
You may try to use it like this:-
exec sp_columns doughnut_list
DESC is not an SQL command, it is used in Oracle. You may also try to check sp_columns
Also if you want to view the table defintion you may try use this:
EXEC sp_help doughnut_list
or may be use a short cut by selecting the table and then CTRL+F1 key
On a side note:-
In Sql Server DESC is the short form of DESCending.
In Oracle it is the short form of DESCribe.
回答2:
DESC
is not an SQL command, it's an SQL*Plus function - i.e., it won't work on other tools, especially if they are used to mange non-oracle databases.
You can use EXEC sp_help 'my_table'
as a way of getting a comparable functionality.
回答3:
You can right click on the table and select:
Script Table As > Create To > New Query Editor Window
The resulting create script will contain the exact table description that you are used to seeing using the SQL Desc command. You can view/copy the field descriptions from there.
Cheers LD
回答4:
EXEC sp_help 'mytable';
this can not be desc the table this only to show all data of the table
fuad alhagami
回答5:
For example : If your table name is CUSTOMERS. Type your Table name as CUSTOMERS in (sql server) query form and select it. Now pressALT+F1. Your table structure will be displayed completely.
回答6:
I believe you should also be able to see the attribute names simply by expanding the table name, click the + sign on the LHS of the table and you should be able to see the attribute names. correct me if m wrong m also new to sql server management studio.
回答7:
Microsoft SQL server2012: Right click on the corresponding Table and click on "Design" link. This will publish the complete Table structure.
来源:https://stackoverflow.com/questions/19882402/not-able-to-use-desc-command-in-sql-server-2012-management-studio