Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old June 27th, 2008, 08:22 PM
lyle fairfield
Guest
 
Posts: n/a
Default Re: Moving a VBA function to SQL server

Tom van Stiphout <no.spam.tom7744@cox.netwrote in
news:kllq04p489upg2bo4slm82v6obgkptb1cf@4ax.com:
Quote:
On Sun, 20 Apr 2008 12:26:14 +0200, "Erik Rudbeck" <no_mails@sorry.dk>
wrote:
>
If optimized is important, do not put procedural code in your T-SQL
procedures. SQL is a set-based language.
>
I can think of a third option: have the query return the raw data
columns, and format the jobheader in your VBA code.
>
-Tom.
<midnight precursor to dementia ramble>

I think there is nothing inherently more efficient or sophisticated in
using SQL udfs or cursors than using VBA, regardless of the snob appeal
for doing so.

It’s likely to be faster for many users to be running VBA procedures and
scanning record sets, each on his/her own workstation with its own CPU
(maybe two or four) than for many users to be running SQL functions and
scanning through cursors all on the same server, unless the record sets
are large enough that time for bringing them over the wire is a factor,
and this often depends on the wire.

Sometimes there are constructions that just seem simpler in SQL, and I
find this particularly so when doing aggregates of aggregates ... of
aggregates, or writing script that alters or creates procedures, views or
functions.

Of course, one may want to keep all the data-centric things in SQL. And
the more that is kept there, the smaller our front end can be and that’s
likely to make it easy to distribute (although clients might say “$16000
for 800 kilobytes? Are you nuts?”)

One must be very careful about writing procedures in SQL that deal with
numbers other than integers. We may think that 1000/ 3 = 333.333.... but
SQL will return 333 unless we explicitly require 1000 to be typed as
float or small money or whatever. Dates can have similar problems. And
NULLs can bite much harder than in VBA where error messages seem to pop
up much more readily than from a server 3000 miles away. If you're going
to write T-SQL with numerical calculations I recommend brushing up on
Convert or Cast beforehand.

</midnight precursor to dementia ramble>




  #2  
Old June 27th, 2008, 08:23 PM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: Moving a VBA function to SQL server

On Tue, 22 Apr 2008 03:52:13 GMT, lyle fairfield <lylefa1r@yah00.ca>
wrote:

Maybe the OP can implement it both ways and report back to us.
It occurred to me that his jobheader is really more a matter of
presentation, so my thinking moves away from the data tier.
It's a good thing cursors are not needed for his solution because they
are exceptionally slow.

-Tom.

Quote:
>Tom van Stiphout <no.spam.tom7744@cox.netwrote in
>news:kllq04p489upg2bo4slm82v6obgkptb1cf@4ax.com :
>
Quote:
>On Sun, 20 Apr 2008 12:26:14 +0200, "Erik Rudbeck" <no_mails@sorry.dk>
>wrote:
>>
>If optimized is important, do not put procedural code in your T-SQL
>procedures. SQL is a set-based language.
>>
>I can think of a third option: have the query return the raw data
>columns, and format the jobheader in your VBA code.
>>
>-Tom.
>
><midnight precursor to dementia ramble>
>
>I think there is nothing inherently more efficient or sophisticated in
>using SQL udfs or cursors than using VBA, regardless of the snob appeal
>for doing so.
>
>It’s likely to be faster for many users to be running VBA procedures and
>scanning record sets, each on his/her own workstation with its own CPU
>(maybe two or four) than for many users to be running SQL functions and
>scanning through cursors all on the same server, unless the record sets
>are large enough that time for bringing them over the wire is a factor,
>and this often depends on the wire.
>
>Sometimes there are constructions that just seem simpler in SQL, and I
>find this particularly so when doing aggregates of aggregates ... of
>aggregates, or writing script that alters or creates procedures, views or
>functions.
>
>Of course, one may want to keep all the data-centric things in SQL. And
>the more that is kept there, the smaller our front end can be and that’s
>likely to make it easy to distribute (although clients might say “$16000
>for 800 kilobytes? Are you nuts?”)
>
>One must be very careful about writing procedures in SQL that deal with
>numbers other than integers. We may think that 1000/ 3 = 333.333.... but
>SQL will return 333 unless we explicitly require 1000 to be typed as
>float or small money or whatever. Dates can have similar problems. And
>NULLs can bite much harder than in VBA where error messages seem to pop
>up much more readily than from a server 3000 miles away. If you're going
>to write T-SQL with numerical calculations I recommend brushing up on
>Convert or Cast beforehand.
>
></midnight precursor to dementia ramble>
>
>
>
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles