Advertisement

08.20.2008 at 06:53AM PDT, ID: 23663067
[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!

7.4

SQL Using User Defind Function to dynamically build "Between" statement for where clause

Asked by brad2575 in SQL Server 2005, SQL Query Syntax

Basically I want to use a return value from a UDF (a string that builds a BETWEEN clause) in a SQL statement.  The details are below:

I have a SP that is dynamically building a BETWEEN for a where clause.  The value of this SP is being stored in a table that I created a UDF to retrieve.  The Return of the UDF can look like this (it can be just one set of Between or have the OR and have a second set, thus the need for the SP):
(ROWID BETWEEN 40001 AND 80000) OR (ROWID BETWEEN 0 AND 30654)

I am dynamically building a SQL statement in an SSIS script task that I want to use the above BETWEEN statement in something like this:

      Select * From TableName
      Where (
            (select dbo.FUN_QueryGenerationGetBetweenValues('Paramater1'))            
      )


Where this lines return value:
 (select dbo.FUN_QueryGenerationGetBetweenValues('Paramater1')) would be:
(ROWID BETWEEN 40001 AND 80000) OR (ROWID BETWEEN 0 AND 30654)

And I want to find a way to make this work.  I am doing something similar using a UDF in the between clause like this:

WHERE ACCTNUM Between
                      (select dbo.FUN_GetMinMaxAcctNum(Paramaters'))
                      and
                  (select dbo.FUN_GetMinMaxAcctNum(Paramaters'))
                )

This works like this in the above but I need to find a way to get the above to work.

I know of a lot of other ways to do it (set the return value to a variable and dynamically build the SQL statement using the variable) but with the existing process I am using in the SSIS package and the way I am running the SSIS and the way I need to generate the BETWEEN statement any other way I can think of would be extremely complicated and really mess up the existing process.

So if I can somehow get this to work the way I have described above that would be great.
Start Free Trial
[+][-]08.20.2008 at 08:09AM PDT, ID: 22270462

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 08:26AM PDT, ID: 22270672

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 09:06AM PDT, ID: 22271176

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 10:00AM PDT, ID: 22271761

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 11:18AM PDT, ID: 22272417

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 12:06PM PDT, ID: 22272843

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 12:06PM PDT, ID: 22272848

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 12:12PM PDT, ID: 22272905

View this solution now by starting your 7-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

Zones: SQL Server 2005, SQL Query Syntax
Sign Up Now!
Solution Provided By: Zberteoc
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10.16.2008 at 06:58AM PDT, ID: 22730905

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 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628