Fawad
Fawad

Reputation: 153

How to rearrange columns in a table in C#

I have created a table "simple gate pass table".

I added some columns: ID, Serial, Date, To, Description, Authorized By.

afterwards, I created this table and later I realized I needed to add 1 more column "From"

but now it won't let me Re-edit existing columns and neither it lets me arrange columns.

enter image description here

Upvotes: 1

Views: 447

Answers (2)

Crozin
Crozin

Reputation: 44376

This is MSSQL-related question and it has nothing to do with C#.


IIRC MSSQL does not allow you to neither rearrange column order nor add column after/before any other. You can only drop column or add one (at the end of the table). If you want to select/display data in some specific order use a SELECT clause with appropriate order, e.g.:

SELECT id, serial, date, from, to, description, authorized_by ...

By the way, from or date are not the very best choices for column names as they are reserved words in most SQL dialects.

Upvotes: 1

Akshey Bhat
Akshey Bhat

Reputation: 8545

you can change order of columns in management studio as follows:

  1. Right click on table name in object explorer and select Design. List of columns will open.
  2. In the newly opened list of columns, left click and drag column name to the position you want.
  3. Press ctrl+s to save.

Upvotes: 0

Related Questions