?
Solved

union query with unique identifier

Posted on 2003-03-18
4
Medium Priority
?
431 Views
Last Modified: 2008-03-03
I have the following stored procedure that I am attempting either to put
into a temp table or do a union query.  I believe the problem may be that
I do not understand the unique identifier guid. Each of the queries work but they are evidently producing different output.  I would appreciate any help. The joins in the last table are on unique identifiers.

CREATE PROCEDURE udp_Lot_CDV_Select_Maker_Prod_Order
  AS
select
right(L.siemens_locn,charindex('-',reverse(L.Siemens_Locn) ) -1 ) as Maker,Code='0',Type='-',Description='None'

FROM udt_Lot_Locations L inner JOIN udt_LOT_Maker_by_Blend M
ON L.Record_ID = M.Maker_Location_ID

where  M.Maker_Blend_Id='{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}'
order by cast(  right(L.siemens_locn,charindex('-',reverse(L.Siemens_Locn)  ) -1  ) as integer)

union

SELECT  
right(L.siemens_locn,charindex('-',reverse(L.Siemens_Locn)  ) -1  ) as Maker,I.Blend_Code as code,

     case
          when  I.Blend_Code='100' then 'M'
          when  I.Blend_Code='102' then 'R'
          when  I.Blend_Code='0' then '-'
                       
     end--case
 as Type, I.Description

FROM udt_Lot_Locations L inner JOIN (udt_Lot_Items I inner JOIN udt_LOT_Maker_by_Blend M
ON I.Record_ID = M.Maker_Blend_ID) ON L.Record_ID = M.Maker_Location_ID
order by cast(  right(L.siemens_locn,charindex('-',reverse(L.Siemens_Locn) ) -1 ) as integer)

GO
0
Comment
Question by:ulu21e
[X]
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
4 Comments
 
LVL 1

Accepted Solution

by:
malekam earned 500 total points
ID: 8160788
Is blend_code integer or character data?

It looks as though you may need to change
Code='0'
to
Code=0

Any luck?
0
 
LVL 32

Assisted Solution

by:Brendt Hess
Brendt Hess earned 500 total points
ID: 8161764
The string representation of a uniqueidentifier (GUID) should not have the braces around it, as I understand this.  So, the query should have the line:

where  M.Maker_Blend_Id='FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'
0
 
LVL 17

Expert Comment

by:walterecook
ID: 10348346
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: malekam {http:#8160788} & bhess1 {http:#8161764}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

walterecook
EE Cleanup Volunteer
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

777 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