[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4662
  • Last Modified:

Convert GUID to String value

I am trying to delete a record from a SQL server table using a GUID.   The WHERE clause in my sql statement uses a field in the table that is defined as a uniqueidentifier and the GUID that i am passing is a string value.

I am get the error "Conversion failed when converting from a character string to uniqueidentifier".   How can i convert the string GUID value so that i can delete this record.   I am using vb.net and SQL Server 2008
0
Mike_Stevens
Asked:
Mike_Stevens
  • 2
1 Solution
 
cdaly33Commented:
If you just need the code in sql you should try:
where columnname = cast("guidyouwanttodelete" as uniqueidentifier)

Open in new window

0
 
cdaly33Commented:
If the issue is in vb you can create a guid object with a specific id like this:
Dim guidtodelete As Guid = New Guid("guidyouwanttodelete")

Open in new window

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now