Solved

Export Field Names to Excel for any table in SQL Server

Posted on 2015-02-16
5
73 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
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:N R
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Got it! Thanks for the help
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now