Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / July 2008

Tip: Looking for answers? Try searching our database.

Select statement comparing a uniqueidentifier field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Suzette - 23 Jul 2008 03:47 GMT
Hi,

I'm attempting to compare information in a uniqueidentifier field using a
select statement and am having fits trying to get it to work.

Here's a sample of my SQL statement.

SELECT Organization.TreatAsTypeOf_ENUM, Organization.OrganizationID,
Organization.Organization, Organization.Email, Organization.URL,
Organization.Phone1, Organization.Phone2, Organization.ExternalAccountID,
Organization.CustomerTypeGUID_FK, Organization.BranchGUID_FK, Address.*,
CustomerType.* , Branch.BranchGUID, Branch.ParentBranchGUID

FROM (Organization LEFT JOIN Address ON Organization.BillToAddressGUID_FK =
Address.AddressGUID)
INNER JOIN CustomerType ON (Organization.BranchGUID_FK =
CustomerType.BranchGUID_FK) AND (Organization.CustomerTypeGUID_FK =
CustomerType.CustomerTypeGUID)

INNER JOIN Branch ON (Organization.BranchGUID_FK = Branch.BranchGUID)

WHERE Branch.ParentBranchGUID = '{65F02099-8E4C-4483-91B8-90AEF2838E76}' AND
CustomerTypeID = 'Home Owner          ' ORDER BY Organization.OrganizationID

The part I'm having issue with is the WHERE statement.   When I try to open
the recordset I get this error:
Syntax error converting from a character string to uniqueidentifier.

If I compare a uniqueidentifier to another one it works but if I try to save
the information and use it, I can't get it to work.

I'm doing this in VB and would LOVE some assistance.  This is making me
crazy and I can't find any information on the web.

Thanks

Sue
Eric Isaacs - 23 Jul 2008 04:08 GMT
You shouldn't need the braces, the { or }, when doing the comparison:

WHERE Branch.ParentBranchGUID =
'65F02099-8E4C-4483-91B8-90AEF2838E76' ...

-Eric Isaacs
Suzette - 23 Jul 2008 04:44 GMT
Thanks, I tried several things but didn't remove the braces.

That worked.
Sue

> You shouldn't need the braces, the { or }, when doing the comparison:
>
> WHERE Branch.ParentBranchGUID =
> '65F02099-8E4C-4483-91B8-90AEF2838E76' ...
>
> -Eric Isaacs
Mariano Gomez - 24 Jul 2008 07:20 GMT
Where Branch.ParentBranchGUID = convert(uniqueidentifier,
'65F02099-8E4C-4483-91B8-90AEF2838E76')

Best regards,
--
MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com

> Hi,
>
[quoted text clipped - 33 lines]
>
> Sue
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.