Thursday, February 9, 2012

Are text pages deleted when a column is converted to varchar

When I change a column from text to varchar using the
design view of a table within Enterprise Manager the
varchar value (less than 8000 characters) appears in the
column but does SQL Server automatically delete the text
values from their pages?

If not are they removed by routine reindex/defrag or
should I create a new table, import from the text as
varchar and drop the old table to make sure the pages
storing the original text version of the values are
deleted?
..morriszone@.hotmail.com (Steve Morris) wrote in message news:<757b6d8f.0404080820.7956cf62@.posting.google.com>...
> When I change a column from text to varchar using the
> design view of a table within Enterprise Manager the
> varchar value (less than 8000 characters) appears in the
> column but does SQL Server automatically delete the text
> values from their pages?
> If not are they removed by routine reindex/defrag or
> should I create a new table, import from the text as
> varchar and drop the old table to make sure the pages
> storing the original text version of the values are
> deleted?
> .

just try:

select * into your_table_bak from your_table

and then try your alter table statment with no risk of dataloss!
alter table *your_table_bak* :-)

if you dont like to read 8000 charakter to find out wether some data
is loss or not try the function
"getsize"

hth

No comments:

Post a Comment