Solved

modify a field

Posted on 1998-12-13
3
171 Views
Last Modified: 2010-03-19
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
Comment
Question by:wyldsj
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 40 total points
ID: 1092253
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
 

Author Comment

by:wyldsj
ID: 1092254
how do I rename a table? Sorry but I am really new to SQL...

wyldsj
0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1092255
Execute sp_rename old_name,new_name
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now