convert/ refractor a column of varchar to uniqueidentifier in Sql Server

201
Views
1
Answers

Hi, I need to convert a column of varchar(50) to uniqueidentifier in Sql server 2008. How to do this?

edit | flag
William Patrick
Asked on: Jun 28, 2011 at 1:22AM

1 Answers

43
1
43

You could try this

alter table message
    alter column externalId uniqueidentifier

If any of the values stored in the column are not guids, you'll get an error like:

Conversion failed when converting from a character string to uniqueidentifier.
edit | flag
Gokul A
Answered on: Jun 28, 2011 at 1:23AM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags