Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
GeneralRe: Separate repeated items Pin
Diego F.26-Aug-04 4:51
Diego F.26-Aug-04 4:51 
GeneralRe: Separate repeated items Pin
LongRange.Shooter26-Aug-04 10:17
LongRange.Shooter26-Aug-04 10:17 
GeneralAccessing the .Net command prompt Pin
Stuggo26-Aug-04 1:46
Stuggo26-Aug-04 1:46 
GeneralRe: Accessing the .Net command prompt Pin
Salil Khedkar26-Aug-04 2:19
Salil Khedkar26-Aug-04 2:19 
GeneralRe: Accessing the .Net command prompt Pin
billb211226-Aug-04 2:38
billb211226-Aug-04 2:38 
QuestionHow to Get All Databases Names in a Sql Server ? Pin
pubududilena26-Aug-04 1:45
pubududilena26-Aug-04 1:45 
AnswerRe: How to Get All Databases Names in a Sql Server ? Pin
David Salter26-Aug-04 2:13
David Salter26-Aug-04 2:13 
AnswerRe: How to Get All Databases Names in a Sql Server ? Pin
Colin Angus Mackay26-Aug-04 2:55
Colin Angus Mackay26-Aug-04 2:55 
Connect to the master database and perform the query
SELECT name from sysdatabases
This will give you a list of all the databases on the server.

[EDIT]

D'Oh! | :doh: I should have read more clearly - you just wanted the database names. Ignore the remainder of this post if all you want is the database names. If you want the table names as well then read on....

[/EDIT]

Then, loop around each of the databases performing the following query
SELECT user_name(uid) AS username, sysobjects.name AS tablename
FROM sysobjects
WHERE xtype='U' OR xtype='S'


xtype='U' is for User tables
xtype='S' is for System tables

From all of this you can get a list of all the tables in all the databases on your server.

Remember, user_name could be important as it is possible to have two tables in one database with exactly the same name, but with different user names. You would use the fully qualified table name to access it. e.g.
theServer.theUser.theTable


Does this help?


"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!


AnswerRe: How to Get All Databases Names in a Sql Server ? Pin
Michael Potter26-Aug-04 6:09
Michael Potter26-Aug-04 6:09 
GeneralRe: How to Get All Databases Names in a Sql Server ? Pin
pubududilena26-Aug-04 17:51
pubududilena26-Aug-04 17:51 
GeneralRe: How to Get All Databases Names in a Sql Server ? Pin
Michael Potter27-Aug-04 3:42
Michael Potter27-Aug-04 3:42 
Generalapplying splitter resizing on tab pages Pin
samithas26-Aug-04 1:21
samithas26-Aug-04 1:21 
GeneralRe: applying splitter resizing on tab pages Pin
Jay Shankar26-Aug-04 1:39
Jay Shankar26-Aug-04 1:39 
GeneralRe: applying splitter resizing on tab pages Pin
Heath Stewart26-Aug-04 8:14
protectorHeath Stewart26-Aug-04 8:14 
GeneralRe: applying splitter resizing on tab pages Pin
Jay Shankar26-Aug-04 16:24
Jay Shankar26-Aug-04 16:24 
GeneralRe: applying splitter resizing on tab pages Pin
Heath Stewart26-Aug-04 8:13
protectorHeath Stewart26-Aug-04 8:13 
GeneralRe: applying splitter resizing on tab pages Pin
Jay Shankar26-Aug-04 16:43
Jay Shankar26-Aug-04 16:43 
GeneralRe: applying splitter resizing on tab pages Pin
Heath Stewart27-Aug-04 8:59
protectorHeath Stewart27-Aug-04 8:59 
Generalrecording screens on PocketPc's Pin
pat27088126-Aug-04 1:09
pat27088126-Aug-04 1:09 
GeneralRe: recording screens on PocketPc's Pin
Heath Stewart26-Aug-04 7:42
protectorHeath Stewart26-Aug-04 7:42 
GeneralRe: recording screens on PocketPc's Pin
Not Active26-Aug-04 9:38
mentorNot Active26-Aug-04 9:38 
GeneralRe: recording screens on PocketPc's Pin
pat27088126-Aug-04 11:14
pat27088126-Aug-04 11:14 
GeneralRe: recording screens on PocketPc's Pin
pat27088126-Aug-04 11:46
pat27088126-Aug-04 11:46 
GeneralSending Faxes Pin
Majid Shahabfar25-Aug-04 22:57
Majid Shahabfar25-Aug-04 22:57 
GeneralRe: Sending Faxes Pin
David Salter26-Aug-04 0:02
David Salter26-Aug-04 0:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.