Column lenth as read from syscolumns table
-
I am trying to come up with a query to determine the structure of a table. So far I have come up with the following query: SELECT SC.name, SC.length FROM syscolumns SC inner join sysobjects SO on SO.id = SC.id where SO.name = 'Customers' The problem is that the "length" column is twice the size it should be. Is there a flaw in my query or do I just have to divide the "length" by two? Thanks James Johnson
-
I am trying to come up with a query to determine the structure of a table. So far I have come up with the following query: SELECT SC.name, SC.length FROM syscolumns SC inner join sysobjects SO on SO.id = SC.id where SO.name = 'Customers' The problem is that the "length" column is twice the size it should be. Is there a flaw in my query or do I just have to divide the "length" by two? Thanks James Johnson
-
Assuming you are using sql server 2000 or later try this:
select * from information_schema.columns where table_name = 'Customers'
It gives you all the information about the table structure. Hope this helpsBob Ashfield Consultants Ltd
What I ended up doing is creating a command to execute the following Select top 1 * from Customers Then DataReader dr = cmd.ExecuteReader(); DataTable dt = dr.GetSchemaTable(); The resulting DataTable contains all of the information I need. Thanks James Johnson
-
What I ended up doing is creating a command to execute the following Select top 1 * from Customers Then DataReader dr = cmd.ExecuteReader(); DataTable dt = dr.GetSchemaTable(); The resulting DataTable contains all of the information I need. Thanks James Johnson