3.枚举指定sqlserver实例所有database的名称 函数: function getalldatabasenamelist (osqlserver : variant ):tstringlist; var snamelist : tstringlist ; i : integer; begin snamelist := tstringlist.create ; for i:= 1 to osqlserver.databases.count do snamelist.append (osqlserver.databases.item(i).name) ; result := snamelist ; end;
4.枚举指定数据库所有table的名称 函数: function getalltablenamelist (osqlserver : variant ; sdatabasename : string ):tstringlist; var odatabase : variant ; snamelist : tstringlist ; i : integer; begin snamelist := tstringlist.create ; odatabase := createoleobject ('sqldmo.database'); odatabase := osqlserver.databases.item(sdatabasename); for i:= 1 to odatabase.tables.count do snamelist.append (odatabase.tables.item(i).name) ; result := snamelist ; odatabase := null ; end;
5.枚举指定数据库所有storeprocedure的名称 函数: function getallstoreprocedurenamelist (osqlserver : variant ; sdatabasename : string ):tstringlist; var odatabase : variant ; snamelist : tstringlist ; i : integer; begin snamelist := tstringlist.create ; odatabase := createoleobject ('sqldmo.database'); odatabase := osqlserver.databases.item(sdatabasename); for i:= 1 to odatabase.storedprocedures.count do snamelist.append (odatabase.storedprocedures.item(i).name) ; result := snamelist ; odatabase := null ; end;