Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default List of tables in SQL server database

Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.

I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.

Any pointers are appreciated.

Regards,
Madiya
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default List of tables in SQL server database

Try this

Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConnString
Set oCat = CreateObject("ADOX.Catalog")
Set oCat.ActiveConnection = oConn

iRow = 1
For Each tbl In oCat.Tables
If (tbl.Type < "SYSTEM TABLE") Then
sTableName = tbl.name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
Debug.Print sTableName
End If
Next tbl

oConn.Close
Set oCat = Nothing


--

HTH

Bob

"Madiya" wrote in message
...
Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.

I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.

Any pointers are appreciated.

Regards,
Madiya



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default List of tables in SQL server database

On Mar 17, 9:43*am, Madiya wrote:
Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.

I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.

Any pointers are appreciated.

Regards,
Madiya


Somebody working with VBA and SQL?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default List of tables in SQL server database

Yes, I posted a reply yesterday.


Bob

"Madiya" wrote in message
...
On Mar 17, 9:43 am, Madiya wrote:
Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.

I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.

Any pointers are appreciated.

Regards,
Madiya


Somebody working with VBA and SQL?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default List of tables in SQL server database

On Mar 18, 8:29*pm, "Bob Phillips" wrote:
Yes, I posted a reply yesterday.

Bob

"Madiya" wrote in message

...
On Mar 17, 9:43 am, Madiya wrote:

Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.


I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.


Any pointers are appreciated.


Regards,
Madiya


Somebody working with VBA and SQL?


Bob,
Thanks but I could not find your reply.
Can you Pl post back here or give me link to that msg pl.

Regards,
Madiya


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default List of tables in SQL server database

This was it.

Try this

Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConnString
Set oCat = CreateObject("ADOX.Catalog")
Set oCat.ActiveConnection = oConn

iRow = 1
For Each tbl In oCat.Tables
If (tbl.Type < "SYSTEM TABLE") Then
sTableName = tbl.name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
Debug.Print sTableName
End If
Next tbl

oConn.Close
Set oCat = Nothing




--

HTH

Bob

"Madiya" wrote in message
...
On Mar 18, 8:29 pm, "Bob Phillips" wrote:
Yes, I posted a reply yesterday.

Bob

"Madiya" wrote in message

...
On Mar 17, 9:43 am, Madiya wrote:

Hi,
How do I list all user tables in a SQL Server database?
Once done I have to passon some commends also to all the listed
tabled.


I already have connection strings and also able to extract records as
pe the criteria from one defined table but do not know how to loop
thru the tables or table properties.


Any pointers are appreciated.


Regards,
Madiya


Somebody working with VBA and SQL?


Bob,
Thanks but I could not find your reply.
Can you Pl post back here or give me link to that msg pl.

Regards,
Madiya


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: VBA Code to extract data from an SQL Server database and put it into Access Database Clinton M James[_2_] Excel Programming 1 October 8th 07 12:44 AM
List external database Tables and Fields CLR Excel Discussion (Misc queries) 1 June 7th 06 08:13 PM
Querying a SQL Server Database Chaplain Doug Excel Programming 6 November 14th 05 04:54 PM
How do I run a SQL query against a MS SQL Server database from exc DPL Excel Discussion (Misc queries) 0 February 8th 05 07:33 PM
Excel Connecting to SQL Server Database - Need your Help Rajesh G Excel Programming 2 February 27th 04 08:01 PM


All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"