473,806 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please convert access query into equivalent stored procedure

2 New Member
Hi ,

Can anybody convert below access query into equivalent stored procedure.
Also please advice in the below query,user defined function of VBA i.e anneeSelection4 1510() has been used in the .MDB file(access project).Now how this can be implemented in the equivalent .ADP(client/server architechture)p roject because obviously anneeSelection4 1510() function will not be recognised by the sql server." (t_activity_mon th.fy)=anneeSel ection41510()) ".
Hope,you will help me out in this.

SELECT t_customer.code _customer, t_customer.name _customer, t_activity_bran d1.no_activity AS Expr1, t_product.code_ product, t_product.produ ct_name, [price_off_amoun t1]*[nb_std_bt_plann ed1] AS mnt1, [price_off_amoun t2]*[nb_std_bt_plann ed2] AS mnt2, [price_off_amoun t3]*[nb_std_bt_plann ed3] AS mnt3, nz([mnt1],0)+nz([mnt2],0)+nz([mnt3],0) AS tot_mnt_mo, t_activity_bran d1.price_off_cu stomer_invoice AS Expr2, t_activity_bran d1.price_off_ac tive_invoice AS Expr3, t_activity.no_a ctivity_month, t_activity_mont h.fy, t_activity_bran d1.activity_bra nd_cancelled AS Expr4, t_activity.acti vity_cancelled
FROM t_product, t_activity_bran d1, t_activity_mont h INNER JOIN (t_customer INNER JOIN t_activity ON t_customer.code _customer = t_activity.code _customer) ON t_activity_mont h.no_activity_m onth = t_activity.no_a ctivity_month
WHERE (((t_activity_m onth.fy)=anneeS election41510() ) AND ((t_activity.ac tivity_cancelle d)=False Or (t_activity.act ivity_cancelled ) Is Null) AND (([t_activity_bran d1].[price_off_diage o_invoice])=True) AND (([t_activity_bran d1].[activity_brand_ cancelled])=False Or ([t_activity_bran d1].[activity_brand_ cancelled]) Is Null));

Many Thanks!

shovan
Dec 13 '07 #1
1 5605
Jim Doherty
897 Recognized Expert Contributor
Hi ,

Can anybody convert below access query into equivalent stored procedure.
Also please advice in the below query,user defined function of VBA i.e anneeSelection4 1510() has been used in the .MDB file(access project).Now how this can be implemented in the equivalent .ADP(client/server architechture)p roject because obviously anneeSelection4 1510() function will not be recognised by the sql server." (t_activity_mon th.fy)=anneeSel ection41510()) ".
Hope,you will help me out in this.

SELECT t_customer.code _customer, t_customer.name _customer, t_activity_bran d1.no_activity AS Expr1, t_product.code_ product, t_product.produ ct_name, [price_off_amoun t1]*[nb_std_bt_plann ed1] AS mnt1, [price_off_amoun t2]*[nb_std_bt_plann ed2] AS mnt2, [price_off_amoun t3]*[nb_std_bt_plann ed3] AS mnt3, nz([mnt1],0)+nz([mnt2],0)+nz([mnt3],0) AS tot_mnt_mo, t_activity_bran d1.price_off_cu stomer_invoice AS Expr2, t_activity_bran d1.price_off_ac tive_invoice AS Expr3, t_activity.no_a ctivity_month, t_activity_mont h.fy, t_activity_bran d1.activity_bra nd_cancelled AS Expr4, t_activity.acti vity_cancelled
FROM t_product, t_activity_bran d1, t_activity_mont h INNER JOIN (t_customer INNER JOIN t_activity ON t_customer.code _customer = t_activity.code _customer) ON t_activity_mont h.no_activity_m onth = t_activity.no_a ctivity_month
WHERE (((t_activity_m onth.fy)=anneeS election41510() ) AND ((t_activity.ac tivity_cancelle d)=False Or (t_activity.act ivity_cancelled ) Is Null) AND (([t_activity_bran d1].[price_off_diage o_invoice])=True) AND (([t_activity_bran d1].[activity_brand_ cancelled])=False Or ([t_activity_bran d1].[activity_brand_ cancelled]) Is Null));

Many Thanks!

shovan
Hi Shovan,

I see your previous thread post was about SQL server too. It seems to me you have an ongoing project to convert an MDB fileserver application to SQL server backend and convert the frontend to an Access ADP Project file not just this query am I correct?

There are several elements of that SQL statement that will not work in SQL server the VBA NZ wrapper function is one of them where you could convert using either coalesce or case expression.

The useage of Access's default EXPR in aliasing column data in my view is pretty useless, it doesn't on the face of it visually 'mean' anything if presented as a header for a column of data in a matrixed display, you really need meaningful names there.

The VBA function whatever it does will have logic in it that needs to be replicated on the server. (whether that maps to a user defined function UDF in SQL Server or worked out within the stored procedure or otherwise via amended SQL remains to be seen. From what I see there it does no more than provide some sort of value for the WHERE clause argument of the SQL thus far)

To convert this properly would require prefixing the relevant tables with the OWNER (dbo) predicate to eradicate conflicts. (Its not always necessary but it is good practice in a multi user environment together with a host of other things not least of which is passing parameters to the 'stored procedure' you require evidently currently contained in the where clause of your posted SQL)

When I convert or create applications in SQL Server I ensure the dog (sql server woof) wags the tail and not the other way round. All of any SQL should sit on top of properly revised table structures having a standard naming convention and with datatypes to suit. Some datatypes and resultant values in Access are different in SQL Server. Inevitably I end up re-writing whole blocks of stuff that hitherto worked perfectly well in Access but which now needs wholesale amendment to suit the new more powerful backend environment properly!

To do it 'properly' rather than peacemeal requires an understanding of what you have there derived from a workable knowledge of your table structure keys, constraints, indexes relationships in other words a full scripted out text file of this, so that it could be replicated and tested. I would not be comfortable with saying "yeaaaah simply paste the SQL into a stored procedure and hope for the best" not good advice for futureproofing in my view.

On the face of it, the posted SQL is simply a single table joined to two others having restrictive crtieria centering on the VBA function return value together with a few boolean true or false values nothing too elaborate.

I am mindful of moving this to the SQL server forum, but will leave it here for the time being because of the Access ADP Project aspect to this (unless admins insist it be moved in which case I will).

Are you able to post your SQL Server table structure as a scripted out text file and also the contents of the VBA function so that we can see what it is doing, in pretty much the same way functionally, as you see? I think that needs dealing with first before any ADP frontend

Regards

Jim :)
Dec 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1697
by: mmm, Pie | last post by:
I never ever thought about this, but recently I made a query in access so I can make a customer mailing list based on relational information and it was so easy to make the query and join tables and assign criterea using access. And I haven't tried or thought about this cause in my own small asp projects I've never used a dbase with queries in it, but after seeing how easy it was, it would save a lot of time from manually writting queries in...
3
5961
by: William Buchanan | last post by:
Hi I have the following stored proc in interbase (which might contain errors - i'm doing it off the top of my head), which I would like to convert into oracle. Can you help? What I want back is a dataset of all the records where Ch_Val is different to the previous value. Thanks for any help. create procedure GetChanges(StartDate timestamp, EndDate timestamp)
29
3714
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them from buying mdb backends. Here's the (million dollar?) questions :) How long and how difficult a process would it be? Which SQL platform would we be best to develop it on?
15
7266
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? Thank you.
4
2433
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO application I will be making, also my first .NET application, so im looking for any help and guidance. Ok, my problems are todo with object and database abstraction, what should i do.
2
2586
by: shovan mohanty | last post by:
Hi, can anybody convert below access NZ()function(Access Queries) to stored procedure: nz(!*!,0) AS po_x_nb_bt_planned Thanks! shovan
2
1894
by: rahuldev999 | last post by:
Hi Can anyone please convert the below access query to the equivalent stored procedure.No problem with the IIF() function but the condition in the "where" clause making problem.so please put some light on the that part. Also how to implement it in the VBA code. SELECT t_activity.no_activity, IIf(="GP","Plan", IIf(="Prov","Appr.",IIf(="Fix","Fix", ))) AS act_steps FROM t_activity_brand, t_customer INNER JOIN t_activity ON ...
2
4092
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges the right to run the stored procedure but not the rights to directly access either the referenced tables or the extended stored procedure. TIA!
13
4177
by: Neil | last post by:
I'm running an update query in SQL 7 from QA, and it runs forever. Has been running for 20 minutes so far! The query is quite simple: update a single field in a table, based on a join with another table. There are a total of 1200 rows that are affected (out of a total of 60,000 in the table). Should not take 20 minutes! Also, retrieving the 1200 rows using the same criteria is instantaneous. Anyone have any idea what's going on? Here's...
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.