Following query gives complete list of tables and views in a SQL database.
USE [DATABASE NAME]
GO
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
Following is the sample query to get column names and data types for selected table:
SELECT
COLUMN_NAME 'COLUMN NAME',
DATA_TYPE 'DATA TYPE',
COULMN_DEFAULT 'COLUMN DEFAULT'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TABLE NAME'
No comments:
Post a Comment