find all databases on a server

BdLm
BdLm used Ask the Experts™
on
title says everything ?

input: servername   output: nr. of database files using delphi 7  and ZEOS database access tools
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018
Commented:
Select * from sys.databases
Haroon Ur RashidSr. Software Engineer
Commented:
Hi BdLm, in sql server you can found any system view which give u information about sql server objects like database, tables, colum and SPs etc. you can find these under system view folder. for database u can use this view "sys.database" as rrjegan17 already told you.
if you need to find more objects in sql server then u may use following system views.
sys.tables, sys.column etc

Author

Commented:
using ZEOS the solution goes than like that :

//  http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_24841933.html?cid=1575#a25657579
procedure TEvalZEOSForm.Button3Click(Sender: TObject);
var  Query:TZQuery;
begin
  ListBox1.Items.Clear;
 
 
  Query:=TZQuery.Create(Self);
  Query.Connection := MSSQL_ZConnection;
  Query.SQL.Add('Select * from sys.databases;');
  try
    Query.Open;
    while(not Query.Eof) do
    begin
      ListBox1.Items.Add(Query.Fields[0].AsString);
      Query.Next;
    end;
  finally
    Query.Close;
    Query.Free;
  end;
 
 
end;

Open in new window

Author

Commented:
with your inputs could write the DELPHI + ZEOS code

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial