Solved

Export Microsoft SQL Server Tables and columns into an excel file

Posted on 2016-10-26
3
80 Views
Last Modified: 2016-10-26
I would like to export all the tables and column names of a said database to an excel file. What is the easiest way of going about this ?

Thanks,
Aditya
0
Comment
Question by:giveindia
[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
3 Comments
 
LVL 12

Accepted Solution

by:
Máté Farkas earned 500 total points
ID: 41860089
USE <SaidDatabase>;

SELECT s.name + '.' + t.name AS table_name, c.name AS column_name
FROM sys.tables t
INNER JOIN sys.schemas s on t.schema_id = s.schema_id
INNER JOIN sys.columns c on t.object_id = c.object_id
ORDER BY table_name, column_name

Open in new window

0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 41860092
Use the Import/Export wizard
ExportData.PNG
And when requesting the source query paste the following:
SELECT t.name AS TableName, c.name AS ColumnName
FROM sys.tables t
	INNER JOIN sys.columns c ON c.object_id = t.object_id
ORDER BY t.name, c.column_id

Open in new window

0
 

Author Closing Comment

by:giveindia
ID: 41860178
Thanks that worked great.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

738 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