Tuesday, February 14, 2012

Converting String -> UniqueIdentifier

I get the following error when I do a CONVERT(UNIQUEIDENTIFIER, 'guid'), where 'guid' is a properly formatted GUID created in VS2005, inside my INSERT statement:

The data was truncated while converting from one data type to another. [ Name of function(if known) = ]

The column I am inserting into has a datatype of uniqueIdentifier.

This is the query I am running:

INSERT INTO [Table] ([guid], [value1], [value2])

VALUES (CONVERT(UNIQUEIDENTIFIER, 'F067FE20-EC76-44C8-9859-FEF222FBC96D'), 'Test, 'Test')

What am I doing wrong?

Matt

This works fine:

Code Snippet

INSERT INTO [Guidtest] ([Field1], [Field2])

VALUES (1, 'F067FE20-EC76-44C8-9859-FEF222FBC96D')

So no need to CONVERT!|||

Thks~

No comments:

Post a Comment