Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dopoto
Starting Member
3 Posts |
Posted - 2005-03-09 : 03:44:42
|
Hi,I am trying to retrieve info about the structure of a MS-SQL Server table using the OpenSchema method. For example, having the table Cars, I want the follwing info returned:Column DataType Length------- -------- ------ID int Name varchar 50...I have used "Set RS = Con.OpenSchema(adSchemaColumns)", but this doesn't seem to offer enough info for the DataType column above - what I need it to return datatypes as you'd see in the Design Mode of the table (int, varchar, ...)Can you guys offer me some help on this? |
|
dopoto
Starting Member
3 Posts |
Posted - 2005-03-09 : 04:20:16
|
Got it! For posterity's sake and for other confused users who might pass by, here it is: strTabl = the table you want information on strDBname = the database name Set objColumnRS = objConn.Execute( _ "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, " & _ "NUMERIC_PRECISION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" & strTbl & _ "' AND TABLE_CATALOG = '" & strDBname & "'") |
|
|
|
|
|