PDA

View Full Version : List of Database in SQL Server



baray98
7th July 2009, 00:22
I am trying to list all Database in an SQL Server. Can someone give me a hint of how should i do this. using QODBC mode in QSqlDatabase?

I am very new to database stuff so please be gentle if my question is really dumb..

baray98

Lykurg
7th July 2009, 07:22
I am trying to list all Database in an SQL Server. Can someone give me a hint of how should i do this. using QODBC mode in QSqlDatabase?

I am very new to database stuff so please be gentle if my question is really dumb..

If you already suspect, that that question isn't so hard to answer, you might want to use the Newbie section. Further what is the connection to Qt? It's pure SQL related and a simple internet search would have surely lead you to the answer:
SHOW DATABASES

jpujolf
7th July 2009, 09:49
Another answer could be this one ( I'm using SQL Server 2000 and SHOW DATABASES doesn't work for me )

I use a select like this :



SELECT NAME
FROM master..sysdatabases
WHERE ( status & 512 = 0 )


NOTE : status 512 means "connected". You can have a lot of databases, but some of them could be disconnected...