[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 95
  • Last Modified:

Export Field Names to Excel for any table in SQL Server

Is there a way to Export Field Names to Excel for any table in SQL Server?
0
SpaceCoastLife
Asked:
SpaceCoastLife
  • 2
  • 2
1 Solution
 
Nathan RileyFounder/CTOCommented:
Sure you can, here's a document, step by step.

https://technet.microsoft.com/en-us/library/ms140052%28v=sql.110%29.aspx
0
 
LIONKINGCommented:
What exactly do you plan on doing with the export? Is it something you want to save?

You can easily see all the columns in a table with this query, which you can then copy+paste into Excel.

Query:
SELECT C.name ColumnName
FROM sys.columns C
	INNER JOIN sys.tables T ON
		C.object_id = T.object_id
WHERE T.name = 'MyTableName'

Open in new window

0
 
SpaceCoastLifeAuthor Commented:
LIONKING: code not working. I get an error on WHERE t.name = "CLIENTS" (or any other table name)
0
 
LIONKINGCommented:
Don't put the quotation symbols, just single quotes.

If the table name is CLIENTS, your query should be:

SELECT C.name ColumnName
FROM sys.columns C
	INNER JOIN sys.tables T ON
		C.object_id = T.object_id
WHERE T.name = 'CLIENTS'

Open in new window

0
 
SpaceCoastLifeAuthor Commented:
Got it! Thanks for the help
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now