Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
afifimk
Starting Member
22 Posts |
Posted - 2012-05-04 : 11:45:42
|
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
15732 Posts |
Posted - 2012-05-04 : 11:50:12
|
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. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-04 : 18:25:02
|
you mean all those hundreds of databases are in same server?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
afifimk
Starting Member
22 Posts |
Posted - 2012-05-09 : 12:20:59
|
It appears that I exaggerated the number a little bit. There are only 49 DB's. SharePoint creates a lot of DB's. |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-05-09 : 15:10:37
|
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 |
|
|
|
|
|