473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Re: Moving a VBA function to SQL server

Tom van Stiphout <no*************@cox.netwrote in
news:kl********************************@4ax.com:
On Sun, 20 Apr 2008 12:26:14 +0200, "Erik Rudbeck" <no******@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>


Jun 27 '08 #1
1 1376
On Tue, 22 Apr 2008 03:52:13 GMT, lyle fairfield <ly******@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.

>Tom van Stiphout <no*************@cox.netwrote in
news:kl********************************@4ax.com :
>On Sun, 20 Apr 2008 12:26:14 +0200, "Erik Rudbeck" <no******@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>
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mahesha | last post by:
Exponential Moving avg is calculated using the formula. EMA = (Today's Price)* K + (EMA yesterday) * (1-K) where K = 2 / (N+1) The user is going to Input the K. It is something like F(N) =...
3
by: Michael . | last post by:
I am trying to move a postgresql database from one server to another. The original server is 7.1.3, and the new one is 7.3.4. I went on the old and used the command: pg_dumpall > dump On...
0
by: Scorpius | last post by:
In an old application on which I am working, in an ASP file there is a server side vbscript function that is creating object of a class created in CPP file -- Server.CreateObject(NAME1.CLASS123)...
6
by: Woody Splawn | last post by:
I have been using SQL Server 2000 on my stand-alone machine as a back-end to a VS.net application. It is time to switch environments and take the application to the customer. I need to install...
2
by: fuzzybr80 | last post by:
I am using MySQL 5.0 with a number of innodb tables whose ibdata files are growing quite quickly and filling up the /var partition (file is /var/mysql/ibdata1). Earlier on I followed instructions...
2
by: Diogo Alves - Software Developer | last post by:
Greetings I would like to knowhow can I put a sliding panel... I've done this: if (panel1.Width < 300) { while (panel1.Width < 300) { panel1.Width = panel1.Width + 40;
7
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
2
by: Paul | last post by:
I am moving an existing app written years ago to a new server. It uses Sigma Template 1.3 and Quickform 1.1.1 and PEAR.php,v 1.1.1.1 2004/02/16 The directory structure is like this: /site...
10
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.