Open store procedure from VBA

Tech-Archive recommends: Fix windows errors by optimizing your registry



I created a sp procedure with multi select statement.

From query analyzer, I open any select, depending of iCrint() value

The following code is example:

ALTER PROCEDURE P2_qrys

--@STR INT

AS

SET NOCOUNT ON

DECLARE @STR INT
SET @STR=dbo.iCrint()

--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-- Allocation
IF @STR=1

SELECT dDatez, Fieldd, Satellite, SepProdz, PipelineID, WellID, TestDate
FROM dbo.L1_AllocationDF
WHERE (Area LIKE dbo.iArea())
ORDER BY dDatez, Sort

--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-- Alloc Factors
IF @STR=5

SELECT dDate, Area, Source, FctOil, FctWater, FctGross, FctGas
FROM dbo.L1_AllocFctrsDF
WHERE (Area LIKE dbo.iArea())
ORDER BY dDate

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-- Chemicals
IF @STR=7

SELECT dDate, Area, ChemicalType, InjectionPoint, ChemicalName, Supplier
FROM dbo.L1_ChemicalsDF
WHERE (Area LIKE dbo.iArea())
ORDER BY dDate, Sort

RETURN

From VBA I open store procedure and sometimes works, sometimes not and
sometimes the select statement doesn't matching with the select statement.

If in the query analyzer I can open the right statement what is wrong? What
can I do?

What I need is:

I have many and many queries. I can create one store procedure for each
query, I did and works fine.

But I would like reduce the number of queries, so I think, I can create a sp
with multi SELECTs and with function IF, I would like to open the query that
I wihs.

Any suggestions?

Thanks,
JP

.



Relevant Pages

  • Re: Open store procedure from VBA
    ... will be hard for SQL-Server to optimize the query plan for each SELECT ... DECLARE @STR INT ... SELECT dDate, Area, Source, FctOil, FctWater, FctGross, FctGas ... I can create one store procedure for each ...
    (microsoft.public.access.adp.sqlserver)
  • Re: delete row query doesnt remove all row when run from access (ms sql)
    ... SET NOCOUNT ON ... DECLARE @dDate AS SMALLDATETIME ... When I run the query from Query Analyzer it does work perfectly. ...
    (microsoft.public.access.queries)
  • Pass parameter to sp
    ... --DECLARE @STR INT ... ORDER BY dDate, Sort ... Public Function testingX() ... Dim cn As adodb.Connection ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Top10 from another view
    ... This query is the best thing that I could make ... In the case of a SP, you can also use a cursor ... without using a primary key but it's much more complicated. ... SELECT dDate, Well ...
    (microsoft.public.access.adp.sqlserver)
  • SQL string problem - pleaze hellp!
    ... The following actually creates a query but with nothing in it, ... where I am sure there are patients with "DDate" in the moth specified by my ... Prev by Date: ...
    (microsoft.public.access.formscoding)