Ever faced a scenario where you wanted to get the list of all columns in a table? Here is the query for that if you are using the Microsoft SQL Server.
SELECT C.Name FROM SysObjects S INNER JOIN SysColumns C ON S.ID=C.ID WHERE ObjectProperty(S.ID,'IsUserTable')=1 AND S.Name='TableName'
Replace ‘TableName’ in the above query with the name of the table whose columns you are looking for.
The query will return the names of all the columns in the given table.






No Comments Yet - be the First!