Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Select statement comparing a uniqueidentifier field

 
   Database Help (Home) -> Programming RSS
Next:  SQL  
Author Message
Suzette

External


Since: Jul 22, 2008
Posts: 2



(Msg. 1) Posted: Tue Jul 22, 2008 7:47 pm
Post subject: Select statement comparing a uniqueidentifier field
Archived from groups: microsoft>public>sqlserver>programming (more info?)

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

 >> Stay informed about: Select statement comparing a uniqueidentifier field 
Back to top
Login to vote
Eric Isaacs

External


Since: May 13, 2008
Posts: 367



(Msg. 2) Posted: Tue Jul 22, 2008 8:08 pm
Post subject: Re: Select statement comparing a uniqueidentifier field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You shouldn't need the braces, the { or }, when doing the comparison:

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

-Eric Isaacs

 >> Stay informed about: Select statement comparing a uniqueidentifier field 
Back to top
Login to vote
Suzette

External


Since: Jul 22, 2008
Posts: 2



(Msg. 3) Posted: Tue Jul 22, 2008 8:44 pm
Post subject: Re: Select statement comparing a uniqueidentifier field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks, I tried several things but didn't remove the braces.

That worked.
Sue

"Eric Isaacs" wrote in message

> You shouldn't need the braces, the { or }, when doing the comparison:
>
> WHERE Branch.ParentBranchGUID =
> '65F02099-8E4C-4483-91B8-90AEF2838E76' ...
>
> -Eric Isaacs
 >> Stay informed about: Select statement comparing a uniqueidentifier field 
Back to top
Login to vote
Mariano Gomez

External


Since: Jul 21, 2008
Posts: 31



(Msg. 4) Posted: Wed Jul 23, 2008 11:20 pm
Post subject: RE: Select statement comparing a uniqueidentifier field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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


"Suzette" wrote:

> 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
>
>
 >> Stay informed about: Select statement comparing a uniqueidentifier field 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How to select specific line in select statement from a giv.. - TableName : TableX Column 1 : name (single line) Column 2 : Comments (multiple line) In "Column2" i have comments which are all about roughtly 20 lines but can vary. What i want to do is for example i want to write a select query which will di...

IF statement within SELECT statement - Is it possible to use an IF statement within a SELECT statement? I am trying to do a query which works out the amount to be billed, and I am having problems working out how to set the rate. The rate varies based on other data in that record. I..

Help with a Select statement - hi there, for an expample: i've got two tables, with 1 and 3 fields on them. like this Forum.ForumID ForumLanguage.ForumID ForumLanguage.ForumLanguage ForumLanguage.ForumTitle Forum contains all Forum records, ForumLanguage contains for each forum a...

Need help with select statement - Hello, I would like to know if it is possible to create a view from the following 2 tables where each client row has the corresponding group codes (CLIENT_GROUP_CODE) for group id's 1,2 and 3. The objective is to have one row for each client and I don'...

Need Help with Select Statement - I need to write a SQL statement to return only orders that share part ID's with other orders from a database. Example: OrderID PartID 12345 12a 12456 12a 23455 11l The statement would need to return the 12345 and 12456 OrderI...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]