I have written a simple SQL query where I declare a variable as an UNIQUEIDENTIFIER
type, and I am trying to insert that into a table where the column is of UNIQUEIDENTIFIER
type. But I get an error message saying
Conversion failed when converting from a character string to uniqueidentifier.
Can anyone help me with this?
Here's my code:
DECLARE @SessionId AS UNIQUEIDENTIFIER;
SET @SessionId='G51F4E30-E1AB-4E7E-8F5B-0E2613DC9001';
PRINT @SessionId;
INSERT INTO [DB_Name].[dbo].[table_name] ([SessionId])
VALUES (@SessionId);
SET @SessionId='G51F4E30-E1AB-4E7E-8F5B-0E2613DC9001';
^
'G' is not a valid hexadecimal character. GUIDs can only consist of characters from 0-9 and A-F.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With