Re: UDF and SQL2000 - Why doesn't this work?
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/13/04
- Next message: Hugo Kornelis: "Re: Opinions on procedural language being introduced into SQL Server 2005"
- Previous message: Hugo Kornelis: "Re: Update Statement Issue??"
- In reply to: Calvin X: "UDF and SQL2000 - Why doesn't this work?"
- Next in thread: G.C.Mandrake: "Re: UDF and SQL2000 - Why doesn't this work?"
- Reply: G.C.Mandrake: "Re: UDF and SQL2000 - Why doesn't this work?"
- Reply: Calvin X: "Re: UDF and SQL2000 - Why doesn't this work?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 14 Aug 2004 01:02:15 +0200
On Fri, 13 Aug 2004 15:38:34 -0400, "Calvin X" <spam
freerobotno_spammingdrone@rotsnail.com> wrote:
>Hi Everyone,
>I am having some problems getting this user defined function to return data
>that I need. Basically This is what I want to do - I have created a query
>that breaks down values for a period start and end into a daily value and I
>want to loop through these values and sum the total value based on the
>period that is passed to the function. The period that is passed is most
>ofter quite different than the period that is defined for the query values
>that are being broken into daily values.
>
>The loop only seems to run through once and then it exits returning either
>NULL or the correct value for one day. When it returns null I run the same
>query against the data source and it gives me the value I need.
>
>Ay help would be great thanks,
>
>Calvin X
(snip)
Hi Calvin,
I'm trying to understand what you're trying to accomplish, but without
knowing the data returned in qryUtVariablesDailyVal and the output you'd
like to get, it gets hard.
If I don't misunderstand your requirements, you can accomplish this lots
easier (and quicker) without looping:
SELECT SUM(DailyVal)
FROM qryUtVariablesDailyVal
WHERE VariableCode = @Var
AND StartDate < @PeriodEnd
AND EndDate >= @PeriodStart
(untested)
Note the reversal of start and end dates - this will include all rows from
the table with the ugly name unless they end before or start after the
specified period.
If this doesn't return the data you need, please post the following:
1. Structure of your table, as DDL (i.e. CREATE TABLE statements; make
sure that all constraints are included, but omit columns that are
irrelevant to the problem);
2. Sample data that illustrates the problem, posted as INSERT statements
(so that I can cut and paste both the DDL and the INSERT statements to
recreate the sample data in my test DB);
3. Expected output from the sample data supplied;
4. A description of the business problem you;re trying to solve.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Hugo Kornelis: "Re: Opinions on procedural language being introduced into SQL Server 2005"
- Previous message: Hugo Kornelis: "Re: Update Statement Issue??"
- In reply to: Calvin X: "UDF and SQL2000 - Why doesn't this work?"
- Next in thread: G.C.Mandrake: "Re: UDF and SQL2000 - Why doesn't this work?"
- Reply: G.C.Mandrake: "Re: UDF and SQL2000 - Why doesn't this work?"
- Reply: Calvin X: "Re: UDF and SQL2000 - Why doesn't this work?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|