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
|