Computing.Net > Forums > Database > SQL Server 7.0

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL Server 7.0

Reply to Message Icon

Name: Daisy B.
Date: May 17, 2009 at 05:06:26 Pacific
OS: Windows XP
Subcategory: MS SQL Server
Comment:

After having created a table and inserted values in it, is there any way to change the length of the datatypes in SQL Server?



Sponsored Link
Ads by Google

Response Number 1
Name: ChrisF
Date: May 26, 2009 at 10:37:33 Pacific
Reply:

You can use the Alter Table command.

Example:

Alter Table <tablename>
Alter Column <columnname> <datatype>

If you had a table named Employee and column LastName that was originally varchar(20) and you wanted to make it varchar(22),use

Alter Table Employee
Alter Column LastName varchar(22)


If you want to make the column shorter and that would result in truncating data you will get an error. In that case, first run an update to truncate the data yourself.
Such as:

Update Employee
Set LastName = Substring(Lastname, 1, 15)

Alter Table Employee
Alter Column Employee varchar(15)


0

Response Number 2
Name: Daisy B.
Date: May 31, 2009 at 05:14:28 Pacific
Reply:

Thanks for your reply. It was a great answer and it worked.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: SQL Server 7.0

SQL Server Reporting Services www.computing.net/answers/dbase/sql-server-reporting-services/722.html

SQL Server 7.0 www.computing.net/answers/dbase/sql-server-70/646.html

SQL Server 7.0 www.computing.net/answers/dbase/sql-server-70/652.html