Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4690
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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