Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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