?
Solved

Export Field Names to Excel for any table in SQL Server

Posted on 2015-02-16
5
Medium Priority
?
83 Views
Last Modified: 2015-02-16
Is there a way to Export Field Names to Excel for any table in SQL Server?
0
Comment
Question by:SpaceCoastLife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Nathan Riley
ID: 40612244
Sure you can, here's a document, step by step.

https://technet.microsoft.com/en-us/library/ms140052%28v=sql.110%29.aspx
0
 
LVL 13

Expert Comment

by:LIONKING
ID: 40612284
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
 

Author Comment

by:SpaceCoastLife
ID: 40612405
LIONKING: code not working. I get an error on WHERE t.name = "CLIENTS" (or any other table name)
0
 
LVL 13

Accepted Solution

by:
LIONKING earned 2000 total points
ID: 40612415
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
 

Author Comment

by:SpaceCoastLife
ID: 40612420
Got it! Thanks for the help
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question