TenVolt
                          Tech Notes
SQL Server > Altering the data type of a field articles:

 • Changing the data type of a field without losing any data

Return to index of articles

Changing the data type of a field without losing any data

Category: SQL Server
Category: Altering the data type of a field

The basic syntax is:

alter table TABLENAME alter field FIELDNAME type

Where type can be something like int, float, varchar(100) etc. If you receive an error when attempting the SQL "alter column" statement, something along the lines of:

Error: The object DF__Web_Pages__Page___07F6335A is dependent on column Web_Pages

Try this first:

alter table web_pages drop constraint DF__Web_Pages__Page___07F6335A

Then the alter column statement should work:

alter table web_pages alter column page_menu varchar(100)

This is caused by the fact that there is some dependency built into the table, perhaps created automatically if you upsized the database from Access.

11/1/2003

 TuneVault
 Music & MP3's
 10v Calendar
 Online & Easy
 Craigger
 Various & Misc.
 RetroVault
 Toys Toys Toys!
   

All contents ©2003 Ten Volt Consulting. All rights reserved.
Unauthorized duplication or use is a violation of applicable laws.
Webmaster Contact