[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Possible to change varbinary values in table to varchar?

Is it possible to change varbinary values in table to varchar? I have set the column as the wrong datatype.  I would rather not lose the data by converting it.
0
mattkovo
Asked:
mattkovo
2 Solutions
 
Brendt HessSenior DBACommented:
Using SSIS, Design the table and change the datatype.  I had no issues doing this, and the data returned perfectly.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
yup possible, it involves these steps

alter table tableName add tmpColumn varchar(100) ---you may have to change the tablename and the fieldlength

update TableName
set tmpColumn = CONVERT(varchar(100), varbinaryColumn )

exec sp_rename  'TableName.varbinaryColumn', 'varbinaryColumn_tmp' ,'COLUMN'
exec sp_rename  'TableName.tmpColumn', 'varbinaryColumn' ,'COLUMN'

--now chall the columns and run the following
--alter table tableName  drop column varbinaryColumn
0
 
mattkovoAuthor Commented:
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now