• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

modify a field

Hi,
  I created a table "test" with a few fields some time ago. One of the field in this table is called "name" and the type was set to be char(20). For some reason, I need to extend this field to be char(40). Since the table has already got lots of data, I wonder what is the easieast way to do this modification while keep all the existing data. Do I HAVE TO create a new table and copy everything over and so on?
  Thanks for your time!

wyldsj
0
wyldsj
Asked:
wyldsj
  • 2
1 Solution
 
Victor SpiridonovCommented:
Yes,you'll have to recreate the table. There is no way in MS SQL to modify column of existing table.
Rename existing table, create new table under old name and then insert into new table from renamed.
0
 
wyldsjAuthor Commented:
how do I rename a table? Sorry but I am really new to SQL...

wyldsj
0
 
Victor SpiridonovCommented:
Execute sp_rename old_name,new_name
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now