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
 General SQL Server Forums
 New to SQL Server Programming
 field posistion

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2008-08-27 : 11:16:11
when i use this query:

select * from wce_contact

all the fields appear as you would expect but in an order which is not to my taste as consecutive fields sometimes dont appear next to each other.

Is there any way of re-ordering the field posistion

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 11:21:33
yes. You specify the column name explicitly and don't use '*'

select field1, field2, field3, . . .
from wce_contact



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-08-27 : 11:24:18
i knew that i just want to use * instead of typing out the field names over and over again
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 11:28:31
it is better to specify the columns required than using '*'. Your application may break when new column is added to the table.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-08-27 : 11:37:01
hmm, it may be better practice but its a bit of a pain specifying the fields each time.

Is there nothing i can do to change the default layout of the fields. eg at the moment it looks like a, d, c, b, e

i want it to read a, b, c, d, e,

there are about 70 fields in my database

JT
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 11:41:05
search in the Script Library for scripts that lists out the column name.

Or you can write your own using
select NAME from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'yourtable' ORDER BY NAME


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-08-27 : 12:03:14
Where is the script library kept?

JT
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 12:12:07
http://www.sqlteam.com/forums/forum.asp?FORUM_ID=11


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -