views:

46

answers:

3

How do I list all the databases for a given sql server 08 instance using sqlcmd?

+5  A: 
sqlcmd -E -S SERVER\INSTANCE -Q "sp_databases"
Heinzi
+3  A: 
EXEC sp_databases

or

SELECT NAME FROM sys.sysdatabases

or

EXEC sp_msForEachDB 'PRINT ''?''';
RedFilter
Up voted for options but accepted Heinzi because it includes the sqlcmd aspect. Thanks!
TheDeeno
+2  A: 

You can use sp_databases stored procedure.

Giorgi