I have a sql server running. Is there anyway to find out the column name with a query. I don't need any data for the same but just the column name. Help guys!
I have a sql server running. Is there anyway to find out the column name with a query. I don't need any data for the same but just the column name. Help guys!
Try this query, may be thsi is what you want :
Code:SELECT column_name FROM information_schema.columns WHERE table_schema = 'schema_name' AND table_name = 'table_name' ;
One other way, that may work :
Code:SELECT table_name, column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'my_table_name'
This may work for SQL 2005 and above versions :
Code:SELECT name FROM sys.columns WHERE [object_id] = OBJECT_ID('dbo.tablename');
Bookmarks