Re: Cursors in functions
anonymous_at_discussions.microsoft.com
Date: 01/22/05
- Next message: Cor Ligthert: "Re: International characters conversion"
- Previous message: Y.Makarounis: "Re: Returning table from UDF"
- In reply to: David Gugick: "Re: Cursors in functions"
- Next in thread: Bob Barrows [MVP]: "Re: Cursors in functions"
- Reply: Bob Barrows [MVP]: "Re: Cursors in functions"
- Reply: Lee Tudor: "Re: Cursors in functions"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 22 Jan 2005 01:29:17 -0800
Hi, this is what I'm after
I got a view like this:
week item used
501 abc 10
502 abc 15
503 abc 5
504 abc 0
505 abc 30
What I want to do is to count the used column for each
week:
week item usedSum
501 abc 10
502 abc 35 (10+15)
503 abc 40 (35+5)
504 abc 40 (40+0)
505 abc 70 (40+30)
Hope you can help me.
thanks
>-----Original Message-----
>Anett wrote:
>> Hi
>>
>> When I want to loop through a result in sp I use Cursor
>> and Fetch. But that does not work in functions (atleast
>> not for me). Anyone that knows what to use instead??
>>
>> /Anett
>
>You should use a set-based approach if at all possible.
Cursors in SQL
>Server are extremely slow. In fact, using functions on
columns in select
>statements can be slow by itself, since SQL Server has to
call the
>function (just like it calls a procedure) for every row
in the result
>set. And if you can imagine returning a 1,000 rows from a
stored
>procedure call, you'd really have 1,001 SP calls if you
attached a
>function to a single column.
>
>If you provide more details about what you are trying to
accomplish, we
>may be able to offer a set-based solution.
>
>
>--
>David Gugick
>Imceda Software
>www.imceda.com
>
>.
>
- Next message: Cor Ligthert: "Re: International characters conversion"
- Previous message: Y.Makarounis: "Re: Returning table from UDF"
- In reply to: David Gugick: "Re: Cursors in functions"
- Next in thread: Bob Barrows [MVP]: "Re: Cursors in functions"
- Reply: Bob Barrows [MVP]: "Re: Cursors in functions"
- Reply: Lee Tudor: "Re: Cursors in functions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|