Below is the effective query to get column names from a SQL table. We will use INFORMATION_SCHEMA to get the task done.
123SELECTCOLUMN_NAMEFROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME = N'TableName'
In the alternate example below, we will use sys.columns to get the task done.
123SELECTnameFROMsys.columnsWHEREobject_id = OBJECT_ID('TableName')
No comments:
Post a Comment