robthomas09
asked on
SQL Cast statement error - varchar to uniqueidentifier
Hello all,
I am trying to insert a 36 character string into a test table as shown below, but I still get the famous "Conversion failed when converting from a character string to uniqueidentifier." Can someone point out the obvious flaw in my query:
create table test3(
id uniqueidentifier
)
declare @id2 varchar(36)
set @id2 = '9D9CB28D-1918-42DB-A7A4-C 8A1FC89209 Q'
insert into test3
(id)
values(
cast(@id2 as uniqueidentifier)
)
Thanks in advance!
I am trying to insert a 36 character string into a test table as shown below, but I still get the famous "Conversion failed when converting from a character string to uniqueidentifier." Can someone point out the obvious flaw in my query:
create table test3(
id uniqueidentifier
)
declare @id2 varchar(36)
set @id2 = '9D9CB28D-1918-42DB-A7A4-C
insert into test3
(id)
values(
cast(@id2 as uniqueidentifier)
)
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have a 'Q' last in the string, that should be an illegal char.
/peter