Posted By

perbitsch on 04/10/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Changing an int column to a varchar column


 / Published in: SQL
 

  1. EXEC sp_rename 'TableName.ColumnName', 'ColumnName_int', 'COLUMN';
  2. GO
  3. ALTER TABLE 'TableName' ADD COLUMN ColumnName VARCHAR(10);
  4. GO
  5. UPDATE TABLE 'TableName' SET ColumnName = CAST(@ColumnName_int AS VARCHAR(10));
  6. GO
  7. ALTER TABLE 'TableName' DROP COLUMN ColumnName;
  8. GO

Report this snippet  

You need to login to post a comment.