Change table to change column name

Here I tried to add an ALTER table to change the column name, but an error occurred.

Alter table [dbo].[Users] 
CHANGE
username UserName varchar(50),
password PassWord varchar(50),
state State int,
name Name varchar(50),
license License varchar(50),
lansno LansNo varchar(50) ,
curcuit_no CurcuitNo varchar(50) ,
communism Communism varchar(100) ,
Olduid OldUid int ,
Is_hunter Is_Hunter bit ,
free_text [FreeText] text ,
country Country varchar(50) ,
curcuit Curcuit varchar(50) ,
license_territory LicenseTerritory [varchar](50) ,
forest Forest varchar(50) ,
association Association varchar(50),
hunt_ar Hunt_Ar varchar(50) ,
area Area varchar(50) ,
contract Contract varchar(50) ,
radio_frequency RadioFrequency varchar(50)
)

This error occurred:

Msg 102, level 15, state 1, line 2
Invalid syntax next to "CHANGE".

So, here I am, I tried this to change the table Change old column name new column name data type .. but here I get an error

+3
source share
2 answers

Try

EXEC sp_RENAME 'Users.username', 'UserName', 'Column'
...
+3
source

Get to know the syntax

ALTER TABLE (Transact-SQL)

If I’m not mistaken, it ALTER COLUMNis notCHANGE COLUMN

Moreover, you should probably read here

SQL SERVER - how to rename a column name or table name

0
source

All Articles