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 |
|
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-03-13 : 11:26:21
|
| Hi,Is there a way to change the order of columns/column ordinance in the table?any suggestions/inputs would helpThanks |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-13 : 11:42:09
|
| Why?In query, you can specify columns in whatever order you want. What the purpose of physically changing the column order?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Swindla
Starting Member
2 Posts |
Posted - 2007-03-25 : 17:34:31
|
| You can display the columns in a table in any order you like.if your select * from tblMySampleTable returns something like this...userID | userFirstName | userLastName | userAge if you wanted to have the age show first, first name show second, the last name show third and the userID last you could write the select query as follows.SELECT userAge, userFirstName, userLastName, userID from tblMySampleTableuserAge | userFirstName | userLastName | userID Hope this helps. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-03-25 : 23:29:42
|
if you absolutely need to do it:0. make a backup.1. export the table using bcp queryout in the column order you want. 2. rename the table. 3. recreate it with the desired column order4. bulk insert the file you created in step 1.5. when you are satisfied everything is ok, you can drop the original table that you renamed in step 2.if you have fks referencing this table, you'll have to drop/recreate them as well.suffice to say it's a headache to do, so I'll repeat the question: why do you need to do it? www.elsasoft.org |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2007-03-26 : 20:09:01
|
| rename the table & create a view.It's a stupid "requirement" though. I'd look at what you're doing. |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2007-03-27 : 06:17:31
|
| Wow, why not just move the columns in Enterprise Manager? Mark the entire column you want to move, release mouse button and then click again and drag it up/down to the position you want.--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-27 : 06:47:04
|
quote: Originally posted by Lumbago Wow, why not just move the columns in Enterprise Manager? Mark the entire column you want to move, release mouse button and then click again and drag it up/down to the position you want.--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand"
Not recommended to do this on large table on production server.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|