Changing column name without loosing table date

Changing column name without loosing table date

Post by Babu » Fri, 11 Apr 2003 16:37:52



hi,
I am required to write a DB Script that will rename a
column in a table without loosing table Data.
The name of the table is 'Gateway'. The columns that i
have in the 'Gateway' table are
GatewayId
UserId
pwd

After running the script the 'Gateway' table should have
the following column Names
GatewayId
UserID
Password

As you can see, i have changed one of the column names
from 'pwd' to 'Password'.
This change of column name should happen without loosing
the rows in the gateway table. Data values in the
old 'pwd' column should be in the new 'password' column.

How do i do this?
TIA,
Babu

 
 
 

Changing column name without loosing table date

Post by Andrew J. Kell » Fri, 11 Apr 2003 17:10:33


See my reply in .programming.  Please don't multi post.

--

Andrew J. Kelly
SQL Server MVP


Quote:> hi,
> I am required to write a DB Script that will rename a
> column in a table without loosing table Data.
> The name of the table is 'Gateway'. The columns that i
> have in the 'Gateway' table are
> GatewayId
> UserId
> pwd

> After running the script the 'Gateway' table should have
> the following column Names
> GatewayId
> UserID
> Password

> As you can see, i have changed one of the column names
> from 'pwd' to 'Password'.
> This change of column name should happen without loosing
> the rows in the gateway table. Data values in the
> old 'pwd' column should be in the new 'password' column.

> How do i do this?
> TIA,
> Babu


 
 
 

1. Changing column name without loosing table date

hi,
I am required to write a DB Script that will rename a
column in a table without loosing table Data.
The name of the table is 'Gateway'. The columns that i
have in the 'Gateway' table are
GatewayId
UserId
pwd

After running the script the 'Gateway' table should have
the following column Names
GatewayId
UserID
Password

As you can see, i have changed one of the column names
from 'pwd' to 'Password'.
This change of column name should happen without loosing
the rows in the gateway table. Data values in the
old 'pwd' column should be in the new 'password' column.

How do i do this?
TIA,
Babu

2. Error While AddNew command

3. Changing column name and type without losing content

4. 8.1.5, 8.0.4 and OAS 4.0.7 coexistence on NT??

5. PLS help: Change field structure without loosing data?

6. JOB Opportunities - Plexus 4GL

7. Accessing another user's table without qualifying table name with the owner-name

8. SSL related question

9. querying column names from a table without the data

10. How to refernce a column without column name

11. How: Pack Paradox-Table without loosing Ref.Integ.

12. audit trails -- looking for the names of tables/columns changed

13. Changing column names in tables