09 August 2010

How do I – Get a list of all databases attached to my SQL Server 2008 R2 database server

Another quick one… You can run this stored procedure:
exec sp_databases
Which should yield the following output:
image_3_2A71938E
or you could try this stored procedure:
exec sp_helpdb
Which would yield some more extended information thus:
image_6_2A71938E
or if you just want the names, you could execute this “undocumented” stored procedure:
exec sp_msforeachdb 'print ''?'''
Which will yield this:
image_9_2A71938E
Or you could do the manual step of executing the following select query:
select name from sys.databases
Which will yield:
image_12_2A71938E

Cheers
C

No comments:

Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.

SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...