[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.6

SQL 2000 Query, trouble with Cast function

Asked by steep5 in Databases Miscellaneous

Tags: 0, null

This question is difficult to word, so I will do my best to be thorough.

Here is a bit of information to start. This query:

SELECT     PART.ID, REQUIREMENT.WORKORDER_TYPE, REQUIREMENT.WORKORDER_BASE_ID, PART.AUTO_BACKFLUSH, PART.PRODUCT_CODE,
                      REQUIREMENT.USER_10, REQUIREMENT.ISSUED_QTY
FROM         PART INNER JOIN
                      REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID
WHERE     (REQUIREMENT.WORKORDER_TYPE = 'W') AND (PART.PRODUCT_CODE = 'SA31') AND (PART.AUTO_BACKFLUSH = 'N') AND
                      (REQUIREMENT.USER_10 = 'Y')
ORDER BY REQUIREMENT.WORKORDER_BASE_ID

Returns no results because there are no Y's in the USER_10 column. If I change the requirement so that I am looking for an AUTO_BACKFLUSH = 'Y', then in that case there are Y's in the USER_10 Column. Fortunately for me, I am only interested in non-autobackflush parts, thus negating the possibility of a Y in USER_10.

That was long winded. Now, I take:

SELECT     PART.ID, REQUIREMENT.WORKORDER_TYPE, REQUIREMENT.WORKORDER_BASE_ID, PART.AUTO_BACKFLUSH, PART.PRODUCT_CODE,
                      REQUIREMENT.USER_10, REQUIREMENT.ISSUED_QTY
FROM         PART INNER JOIN
                      REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID
WHERE     (REQUIREMENT.WORKORDER_TYPE = 'W') AND (PART.PRODUCT_CODE = 'SA31') AND (PART.AUTO_BACKFLUSH = 'N') AND
                (REQUIREMENT.ISSUED_QTY > REQUIREMENT.USER_10)
ORDER BY REQUIREMENT.WORKORDER_BASE_ID

And SQL 2000 tells me that it cannot assign a varchar column to a numeric column. I know this, so I then add in the cast function:

SELECT     PART.ID, REQUIREMENT.WORKORDER_TYPE, REQUIREMENT.WORKORDER_BASE_ID, PART.AUTO_BACKFLUSH, PART.PRODUCT_CODE,
                      REQUIREMENT.USER_10, REQUIREMENT.ISSUED_QTY
FROM         PART INNER JOIN
                      REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID
WHERE     (REQUIREMENT.WORKORDER_TYPE = 'W') AND (PART.PRODUCT_CODE = 'SA31') AND (PART.AUTO_BACKFLUSH = 'N') AND
                (REQUIREMENT.ISSUED_QTY > cast(REQUIREMENT.USER_10 as int))
ORDER BY REQUIREMENT.WORKORDER_BASE_ID

Furthermore, if there are any <NULL> values in this column, I want to change them to zero as such:

SELECT     PART.ID, REQUIREMENT.WORKORDER_TYPE, REQUIREMENT.WORKORDER_BASE_ID, PART.AUTO_BACKFLUSH, PART.PRODUCT_CODE,
                      REQUIREMENT.USER_10, REQUIREMENT.ISSUED_QTY
FROM         PART INNER JOIN
                      REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID
WHERE     (REQUIREMENT.WORKORDER_TYPE = 'W') AND (PART.PRODUCT_CODE = 'SA31') AND (PART.AUTO_BACKFLUSH = 'N') AND
               (REQUIREMENT.ISSUED_QTY > cast(isnull(REQUIREMENT.USER_10,'0') as int))
ORDER BY REQUIREMENT.WORKORDER_BASE_ID

Beautiful. There is a problem, though, and this is where I need help. SQL 2000 now tells me:

"Syntax error converting the varchar value 'Y' to a column of data type int."

But wait, there aren't any Y's in this select statement! I have a feeling this is going to be one of those "You idiot!" solutions that just needs a fresh set of eyes. This would be easier if you had the data to work with, and for that I apologize. I should mention that I get the same result whether I use cast or convert, isnull or coalesce. Thanks in advance for your help!
[+][-]07/20/05 09:09 AM, ID: 14486173Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/20/05 09:32 AM, ID: 14486443Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/20/05 09:51 AM, ID: 14486648Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/20/05 11:41 AM, ID: 14487877Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/20/05 12:07 PM, ID: 14488185Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/20/05 01:59 PM, ID: 14489369Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/20/05 02:10 PM, ID: 14489476Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/20/05 02:31 PM, ID: 14489660Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/20/05 02:32 PM, ID: 14489678Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/20/05 07:19 PM, ID: 14491071Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/21/05 06:07 AM, ID: 14493043Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/05 11:03 AM, ID: 14495491Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/21/05 11:13 AM, ID: 14495624Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/05 11:19 AM, ID: 14495707Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/05 11:47 AM, ID: 14496045Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/05 11:50 AM, ID: 14496075Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/21/05 12:10 PM, ID: 14496306Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/05 12:12 PM, ID: 14496317Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Databases Miscellaneous
Tags: 0, null
Sign Up Now!
Solution Provided By: rafrancisco
Participating Experts: 5
Solution Grade: A
 
[+][-]07/21/05 01:01 PM, ID: 14496822Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/08/06 09:08 PM, ID: 15646072Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/13/06 05:08 PM, ID: 15697740Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81