List All Columns in Table SQL
This query will list all the column names in a particular table. This query only list number types, but you can modify it to list other types as well. This can be useful if your table has a lot of columns and you want to easly get a list of them.
SELECT (QUOTENAME(COLUMN_NAME)) as columnname
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME('[dbo].[Component]', 2)
AND TABLE_NAME = PARSENAME('[dbo].[Component]', 1)
AND DATA_TYPE IN ('int','bigint','smallint','tinyint','decimal','float','real')

0 comments:
Post a Comment