PDA

Click to See Complete Forum and Search --> : Code to list DBF tables & Tables fields


oramirez
Aug 23rd, 2000, 04:03 PM
Hello:

I need to build SQL interactively.

I mean having a working directory I need
to list the tables there, choose one and then
in a combo box, I think, see its fields to choose
one, and maybe the values to build the SQL.

Can anybody please help me with this?

thanks in advance

AKA
Aug 24th, 2000, 12:48 PM
Have you discovered the system objects in MS SQL Server ?

Enter the SQL Server Enterprise Manager and click on your server, /Action /Edit SQL Server Registration and check the "Show system database and system objects" CheckBox.

You now for example can look at the two wievs named TABLES and COLUMNS.

You could also directly look at the system tables.

This query will give you all user defined tables ('U') and all user defined views ('V').

SELECT
name,
id
FROM
sysobjects
WHERE
( xtype = 'U' OR
xtype = 'V')
AND
userstat = 1


And use the returned Id to get the columns


SELECT
name
FROM
syscolumns
WHERE
id = 117575457 /* The number for one of my own table */


I think that this will get you started. I don't know more for now because I figured it out during the day and it is possible that I have missed something.