/* ValidateGUID.sql:
Ever have a GUID in a VARCHAR format and need to use it to query or update a table, but if the
data is invalid, you get the error:
"Conversion failed when converting from a character string to uniqueidentifier."
*/DECLARE @AuthorizationCode as VARCHAR(64), @bValidAuth BIT
SET @bValidAuth = 1
SET @AuthorizationCode = 'D12FC09D-20A6-4D31-A14D-B5454EEDF453'BEGIN TRYDECLARE @GUID uniqueidentifier
SET @GUID = CONVERT(uniqueidentifier, @AuthorizationCode)
END TRYBEGIN CATCHSET @bValidAuth = 0
END CATCHSELECT @bValidAuth