Re: Stored Procedure woes!!
From: Ivan Debono (ivanmdeb_at_hotmail.com)
Date: 10/18/04
- Next message: Scorcel: "Re: Rare Query?"
- Previous message: Bonj: "establishing cause of access violation?"
- In reply to: Ivan Debono: "Re: Stored Procedure woes!!"
- Next in thread: Uri Dimant: "Re: Stored Procedure woes!!"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 18 Oct 2004 14:39:24 +0200
I mean, event without parameters.
"Ivan Debono" <ivanmdeb@hotmail.com> schrieb im Newsbeitrag
news:upn5e4QtEHA.1720@TK2MSFTNGP14.phx.gbl...
> The problem is that I'm using a complex sql statement with multiple
unions.
>
> How can I execute the SP within a sql statement??
>
>
> "Uri Dimant" <urid@iscar.co.il> schrieb im Newsbeitrag
> news:%23b1c5zQtEHA.1216@TK2MSFTNGP10.phx.gbl...
> > Ivan
> > Its invalid syntax with SQL Server
> > You cannot do that
> > Instead ,create a temp table
> > create table #Temp
> > (
> > col ...
> > col1
> > col2...
> > )
> > Insert Into #Temp EXEC yourSP and then use a JOIN with another table
> >
> > Please ,note that the number of columns in #TEMP table must match with a
> > numbers of columns are returned by your SP
> >
> >
> >
> >
> >
> >
> > "Ivan Debono" <ivanmdeb@hotmail.com> wrote in message
> > news:eTnuFwQtEHA.376@TK2MSFTNGP09.phx.gbl...
> > > Hi all,
> > >
> > > I have the following stored procedure:
> > >
> > > CREATE PROCEDURE gross_net_vat_calculation @id_no_vat int,
@booking_date
> > > datetime, @amount_gross money
> > > as
> > >
> > > select DMBTR =
> > > case when percentage = 0 then @amount_gross else
> > > round((@amount_gross / (100+percentage) * 100),2)
> > > end,
> > > MWSTS =
> > > case when percentage = 0 then 0 else
> > > round((@amount_gross / (100+percentage) * percentage),2)
> > > end,
> > > sap_code as MWSKZ
> > > from vat_ranges
> > > where id_no_vat_fid = @id_no_vat and
> > > runningfrom <= @booking_date and
> > > runningto >= @booking_date
> > > GO
> > >
> > > It works fine when I call it alone (with constants as parameters).
> > >
> > > But I want to execute the procedure within a SELECT statement, where
the
> 3
> > > parameters are fields from a table, sort of:
> > >
> > > select *, exec gross_net_vat calculation vat_id, booking_date,
> > > booking_amount from bookings
> > >
> > > But obviously it's not working :(
> > >
> > > Anybody has an idea how to get it to work??
> > >
> > > Thanks,
> > > Ivan
> > >
> > >
> >
> >
>
>
- Next message: Scorcel: "Re: Rare Query?"
- Previous message: Bonj: "establishing cause of access violation?"
- In reply to: Ivan Debono: "Re: Stored Procedure woes!!"
- Next in thread: Uri Dimant: "Re: Stored Procedure woes!!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|