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;
When sorting your result set in descending order, you use the DESC attribute in your ORDER BY clause. For example: SELECT last_name FROM employees WHERE first_name = 'Sarah' ORDER BY last_name DESC; This SQL Server ORDER BY example would return all records sorted by the last_name field in descending order.
Since in database we have tables, that's why we use DESCRIBE or DESC(both are same) command to describe the structure of a table. Syntax: DESCRIBE one; OR DESC one; Note : We can use either DESCRIBE or DESC(both are Case Insensitive).
Just select table and press Alt + F1 , it will show all the information about table like Column name, datatype, keys etc.
The DESC command is used to sort the data returned in descending order.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With