June 5, 2008 at 2:52 am
i have to update position table,
in this table one cloumn name is SURVEY_JOB_TITLE ,
i wnat ot update this cloumn name as SURVEY_JOB_CODE,
AND also want to change datatype as int ,
how i do this ?
plesase help me 🙂
CREATE TABLE POSITION
(
POSITION_ID INT IDENTITY(1,1),
COMPANY_ID INT NOT NULL,
COMPANY_JOB_TITLE VARCHAR(255) NOT NULL,
SURVEY_JOB_TITLE VARCHAR(255) NOT NULL,
JOB_MATCH VARCHAR(255) NOT NULL,
JOB_MATCH_COMMENTS VARCHAR(2000),
GEOGRAPHIC_RESPOSIBILITY VARCHAR(255),
EMPLOYEES_SUPERVISED INT,
REPORTING_LEVEL INT,
MEMEBER_OF_EXECUTIVE_GROUP VARCHAR(255),
INTERNATIONAL_RESPONSIBILITY VARCHAR(255)
)
June 5, 2008 at 3:12 am
hi,
do you have data in that table? if so, existing data should support the conversion to int
try to do this change in Management Studio (right click on the table, 'modify'), you cannot do this easy in a query (in brief, you would have to use a temp table, create a new table with the desired structure and then copy the data to the new table; discard the old table and rename the newly created; but you should pay attention to indexes, constraints, etc - though it does not seem that you have any:) )
dragos
June 5, 2008 at 6:20 pm
Alter the table to add the new column SURVEY_JOB_CODE.
Execute an update statement which converts the data from SURVEY_JOB_TITLE (or do a lookup using a JOIN, if that's necessary) and put it in SURVEY_JOB_CODE.
Alter the table to drop the SURVEY_JOB_TITLE column.
Depending on the # of rows you have, these operations may take a while.
K. Brian Kelley
@kbriankelley
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply