Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Modifiying a field in table

Author  Topic 

Pasi
Posting Yak Master

166 Posts

Posted - 2014-01-21 : 16:01:33
HI,

I have a field called "assescode9" in a table called "Assessment" which has the length of "6" and I want to change this length to 7 or 8 in SQL. I tried right click on the field and modify but when I want to save it says you can not save the changes because it requires a Drop table and recreate or you do not have an option enabled to recreate the table, how do I do this?

I have never done dropping a table and recreate it?

Thanks!
Pasi

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-01-21 : 16:16:13
ALTER TABLE <TableName>
ALTER COLUMN assescode9 VARCHAR(8)


I assumed VARCHAR, but if not just replace that with the correct datatype.
Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-01-21 : 16:28:24
Thank you! I did it but when I run a select statement in sql I still see the filed length 6? I see that it update the column but when I go to my application and bring up that filed the field still 6 and it is grayed out?
Pasi

quote:
Originally posted by Lamprey

ALTER TABLE <TableName>
ALTER COLUMN assescode9 VARCHAR(8)


I assumed VARCHAR, but if not just replace that with the correct datatype.

Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-01-21 : 16:35:54
Another word, I also tried following :

Begin Tran T1
update template_fields set field_length='7' where field_name='assesscode9' and field_length='6' and template_id='4879'

it changed the field in sql but when I try to open this template it gives me an SQL error and can not open unless I roll back the the TRAN?
Go to Top of Page
   

- Advertisement -