I want to get all table names and fields in that table from a particular database. Please help me to solve this.
To show table properties in the Properties window. In Object Explorer, select the table for which you want to show properties. Right-click the table and choose Properties from the shortcut menu. For more information, see Table Properties - SSMS.
In SQL, to retrieve data stored in our tables, we use the SELECT statement. The result of this statement is always in the form of a table that we can view with our database client software or use with programming languages to build dynamic web pages or desktop applications.
The DESC command is used to sort the data returned in descending order.
Try looking at the sys.objects
and sys.columns
tables:
SELECT * FROM SYS.OBJECTS
WHERE TYPE = 'U'
Would give you all of the tables in that database (Type U)
SELECT 'Table name : ' + so.name, ' Column Name: ' + sc.name FROM SYS.OBJECTS so
INNER JOIN sys.columns sc ON sc.OBJECT_ID = so.OBJECT_ID
WHERE TYPE = 'U'
Would give you all of the tables in that database and the column names. You could filter on these queries and do WHERE so.name = 'Your Table'
http://msdn.microsoft.com/en-us/library/ms190324.aspx
use the syntax :-sp_help your table name
like this
sp_help Payroll_Shift
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