To know the name of the columns of the tables I use the following syntax:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
To which it throws me all the names of the columns of the tables of my database.
With what function could I know what are the names of the columns that only my table has TAB_1
?
The option to consult the whole table does not seem attractive to me.
SELECT * FROM TAB_1
Is there any function?
Thank you very much in advance
pst: Just starting out in SQL.
The information is in the table itself that you are consulting, you simply have to filter the columns of the table that you are interested in seeing, since you are only interested in the name of the columns, use this query:
Don't forget to include the schema name in your filter, as there may be different tables with the same name in different schemas.
So that eventually this question remains canonical, I would add the way to know the column names in versions of SQL Server older than 2005 (?), but still valid:
By running
sp_columns
Using the pseudo table
syscolumns
The following script can be useful to get the name of the columns and some additional information