sqlcmd -E -S SERVER\INSTANCE -Q "sp_databases"
Notes:
-E: Use a trusted connection (“Windows authentication”). Replace by-U username -P passwordfor SQL Server authentication.-S SERVER\INSTANCE: The instance of SQL Server to which to connect. If you don’t know the name of your instance, you can usesqlcmd -Lto get a list.-Q: The query to execute. The uppercaseQcauses sqlcmd to exit after executing the query.