Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Convert GUID to String value

Posted on 2009-03-30
2
4,644 Views
Last Modified: 2013-11-26
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
Comment
Question by:Mike_Stevens
  • 2
2 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24022804
If you just need the code in sql you should try:
where columnname = cast("guidyouwanttodelete" as uniqueidentifier)

Open in new window

0
 
LVL 9

Accepted Solution

by:
cdaly33 earned 500 total points
ID: 24022816
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question