SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Export Database Names to a File
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

afifimk
Starting Member

USA
19 Posts

Posted - 05/04/2012 :  11:45:42  Show Profile  Reply with Quote
I have many databases and want to export the database names only to an external file (Excel, etc.). I can do this manually but it will take a long time because I have hundreds of databases and most of them have a unique GUID appended to the name. I am just looking for an easy way to get this done.

robvolk
Most Valuable Yak

USA
15568 Posts

Posted - 05/04/2012 :  11:50:12  Show Profile  Visit robvolk's Homepage  Reply with Quote
Using the command line:
bcp "select name from sys.databases where database_id>4" queryout databases.csv -Sserver -T -c
Change "server" to match your SQL Server's name.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
48076 Posts

Posted - 05/04/2012 :  18:25:02  Show Profile  Reply with Quote
you mean all those hundreds of databases are in same server?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

afifimk
Starting Member

USA
19 Posts

Posted - 05/09/2012 :  12:20:59  Show Profile  Reply with Quote
It appears that I exaggerated the number a little bit. There are only 49 DB's. SharePoint creates a lot of DB's.
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
1795 Posts

Posted - 05/09/2012 :  15:10:37  Show Profile  Visit jackv's Homepage  Reply with Quote
SQLCMD -E -S MY_SERVER_NAME -Q "select name from sys.databases where database_id>4" -o my_output_file.txt


Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000