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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 information_schema.columns ordring problem

Author  Topic 

jparker
Posting Yak Master

118 Posts

Posted - 2005-02-09 : 05:09:58
I am doing the following statement to return all the column names in the table

select column_name from information_schema.columns where table_name = 'mytable'

the problem I am having is they aren't being returned in the order that they are in in the table which means when I try and do an insert they are going to the wrong fields.

How do I return all the fields in the order that they appear in design view for example?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-02-09 : 05:14:15

select column_name from information_schema.columns where table_name = 'mytable' order by Ordinal_Position

Madhivanan
Go to Top of Page

jparker
Posting Yak Master

118 Posts

Posted - 2005-02-09 : 05:17:03
cheers dude spot on
Go to Top of Page
   

- Advertisement -