Can I practically reorder columns in a table?

If I'm including a column to a table in Microsoft SQL Server, can I regulate where the column is presented practically in questions?

I do not intend to tinker the physical format of columns on disk, yet I would love to practically team columns with each other when feasible to make sure that devices like SQL Server Management Studio checklist the materials of the table in a hassle-free means.

I recognize that I can do this via SQL Management Studio by entering into their "layout" setting for tables and also dragging the order of columns about, yet I would certainly such as to have the ability to do it in raw SQL to make sure that I can execute the getting scripted from the command line.

0
2019-05-04 04:08:35
Source Share
Answers: 3

If I recognize your inquiry, you intend to influence what columns are returned first, 2nd, 3rd, etc in existing questions, right?

If every one of your questions are created with SELECT * FROM TABLE - after that they will certainly turn up in the result as they are outlined in SQL.

If your questions are created with SELECT Field1, Field2 FROM TABLE - after that the order they are outlined in SQL does not issue.

0
2019-05-10 10:39:13
Source

You can refrain this programatically (in a secure manner in which is ) without developing a new table.

What Enterprise Manager does when you devote a reordering is to create a new table, relocate the information and afterwards delete the old table and also relabel the new table to the existing name.

If you desire your columns in a certain order/grouping without modifying their physical order, you can create a sight which can be whatever you want.

0
2019-05-07 21:38:34
Source

When Management Studio does it, it's developing a short-lived table, duplicating every little thing throughout, dropping your initial table and also relabeling the short-lived table. There's no straightforward equal T-SQL declaration.

If you do not expensive doing that, you could constantly create a sight of the table with the columns in the order you would certainly such as and also make use of that?

Modify : defeated!

0
2019-05-07 21:36:25
Source