|
 |
asp_databases thread: getting table names
Message #1 by "Preston" <rowlettep@s...> on Tue, 20 Mar 2001 14:01:21
|
|
Hi all,
Is there a way through asp to connect to a database on sql server and
retrieve all the tables that are in that database. I only need the table
names. One of the dba's has changed the name of one of the tables that I
am working with, he is not available right now and I need to be able to
querry the table asap. So again is there any way to get a table name out
of a sql server database through asp. Please, any help would be greatly
appreciated.
Thank You,
Preston
Message #2 by Gregory_Griffiths@c... on Tue, 20 Mar 2001 14:13:59 +0000
|
|
You may be able to use :
select table_name from all_tables
works in Oracle.
> -----Original Message-----
> From: rowlettep@s... [mailto:rowlettep@s...]
> Sent: 20 March 2001 14:01
> To: asp_databases@p...
> Subject: [asp_databases] getting table names
>
>
> Hi all,
> Is there a way through asp to connect to a database on sql
> server and
> retrieve all the tables that are in that database. I only
> need the table
> names. One of the dba's has changed the name of one of the
> tables that I
> am working with, he is not available right now and I need to
> be able to
> querry the table asap. So again is there any way to get a
> table name out
> of a sql server database through asp. Please, any help would
> be greatly
> appreciated.
> Thank You,
> Preston
Message #3 by "Blake, Shane" <Shane.Blake@p...> on Tue, 20 Mar 2001 10:31:05 -0500
|
|
that's only for oracle...
for sql 7, try :
select * from sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1
shane
-----Original Message-----
From: Gregory_Griffiths@c...
[mailto:Gregory_Griffiths@c...]
Sent: Tuesday, March 20, 2001 9:14 AM
To: ASP Databases
Subject: [asp_databases] RE: getting table names
You may be able to use :
select table_name from all_tables
works in Oracle.
> -----Original Message-----
> From: rowlettep@s... [mailto:rowlettep@s...]
> Sent: 20 March 2001 14:01
> To: asp_databases@p...
> Subject: [asp_databases] getting table names
>
>
> Hi all,
> Is there a way through asp to connect to a database on sql
> server and
> retrieve all the tables that are in that database. I only
> need the table
> names. One of the dba's has changed the name of one of the
> tables that I
> am working with, he is not available right now and I need to
> be able to
> querry the table asap. So again is there any way to get a
> table name out
> of a sql server database through asp. Please, any help would
> be greatly
> appreciated.
> Thank You,
> Preston
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #4 by Sdavis@C... on Tue, 20 Mar 2001 10:08:02 -0500
|
|
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
This should do it.
Samira
-----Original Message-----
From: Preston [mailto:rowlettep@s...]
Sent: Tuesday, March 20, 2001 9:01 AM
To: ASP Databases
Subject: [asp_databases] getting table names
Hi all,
Is there a way through asp to connect to a database on sql server and
retrieve all the tables that are in that database. I only need the table
names. One of the dba's has changed the name of one of the tables that I
am working with, he is not available right now and I need to be able to
querry the table asap. So again is there any way to get a table name out
of a sql server database through asp. Please, any help would be greatly
appreciated.
Thank You,
Preston
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #5 by "yuenkit" <janet_smith2000@y...> on Tue, 20 Mar 2001 16:05:29
|
|
i have tried 2 ways:
1)
set objRS = server.CreateObject("ADODB.RecordSet")
objRS.Open strSQL, objConn
For Each Item in objRS.Fields
response.Write Item.Name
Next
2)
'-----Establish Connection-----
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("yuenkit.mdb") &_
";Persist Security Info=False"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
'-----Request Data-----
Set objDict = server.CreateObject("Scripting.Dictionary")
Set objSchema = objConn.OpenSchema (adSchemaColumns)
objSchema.MoveFirst
Do Until objSchema.EOF
Response.Write objSchema("Table_Name")
objSchema.MoveNext
Loop
but for the 2nd method, it will sure giving u more table that u want, like
sistem table.
i hope these is what u want. yeah!
> Hi all,
> Is there a way through asp to connect to a database on sql server and
> retrieve all the tables that are in that database. I only need the table
> names. One of the dba's has changed the name of one of the tables that I
> am working with, he is not available right now and I need to be able to
> querry the table asap. So again is there any way to get a table name out
> of a sql server database through asp. Please, any help would be greatly
> appreciated.
> Thank You,
Message #6 by John Pirkey <mailjohnny101@y...> on Tue, 20 Mar 2001 08:10:33 -0800 (PST)
|
|
You could also do this:
SELECT * FROM SysObjects (nolock)
WHERE xType = 'U'
it should return the same set of tables as the query below, but it avoids doing a
system function in the WHERE clause.
be sure you are in the database you want to be in because eash database has a
SysObjects table. If you connect using a DSN, and you dont change the default
database, chances are, you'll be connecting to the Master database.
just another trick for your bag.
john
--- "Blake, Shane" <Shane.Blake@p...> wrote:
> that's only for oracle...
>
> for sql 7, try :
>
> select * from sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1
>
> shane
>
> -----Original Message-----
> From: Gregory_Griffiths@c...
> [mailto:Gregory_Griffiths@c...]
> Sent: Tuesday, March 20, 2001 9:14 AM
> To: ASP Databases
> Subject: [asp_databases] RE: getting table names
>
>
> You may be able to use :
>
> select table_name from all_tables
>
> works in Oracle.
>
> > -----Original Message-----
> > From: rowlettep@s... [mailto:rowlettep@s...]
> > Sent: 20 March 2001 14:01
> > To: asp_databases@p...
> > Subject: [asp_databases] getting table names
> >
> >
> > Hi all,
> > Is there a way through asp to connect to a database on sql
> > server and
> > retrieve all the tables that are in that database. I only
> > need the table
> > names. One of the dba's has changed the name of one of the
> > tables that I
> > am working with, he is not available right now and I need to
> > be able to
> > querry the table asap. So again is there any way to get a
> > table name out
> > of a sql server database through asp. Please, any help would
> > be greatly
> > appreciated.
> > Thank You,
> > Preston
|
|
 |