Alphabetize fields in a table

  • I'm fairly new to the DBA world so please be kine. Our developers have asked that we alphabetize the fields in each table. Can someone point me in the right direction to write a quick script to do this?

     

    Thanks!

  • Unless someone has a script to do this....

    I would probably generate scripts for all the tables, change the order, and create new tables either with new names or same names in a different db.

    Then either INSERT INTO or a DTS Export into the other tables.

    Is this really a legitimate request?

    Regards,

    RandyB

  • By "Alphabatize the fields" do they mean return a resultset with the fields in order or they just want a sorted list of fields in a table?

    For the first scenario, just create a view, for the second, try this:

    select sc.name from

     syscolumns sc,

    sysobjects so

    where sc.id = so.id and

    so.name = '<table name'

    order by sc.name

  • Why on earth would someone want to alphabetize the fields in the table? What if you need to add another field? Drop constraints, copy data out, drop table, re-create table, copy data in, re-create constraints, re-code app? Nonsense.

  • Agreed. This is a moronic request from developers and demonstrates a *complete and utter* non-understanding of database fundamentals.

    You should push back on the request and request your company hire more competent developers.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply