By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,639 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,639 IT Pros & Developers. It's quick & easy.

Pass parameter to nested view?

P: n/a
Hi,

I have a View that groups and sums up totals.

This View is then nested within in another View and used (it needs to
be done like this). What i need to do is to be able to vary the
records in the nested query by specifying dates. These would somehow
need to be passed to the nested query.

I've looked into stored procedures/functions but am still stumped on
how to do this.

Can anyone help?
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Forgone Conclusion" <ba********@hotmail.com> wrote in message
news:dc**************************@posting.google.c om...
Hi,

I have a View that groups and sums up totals.

This View is then nested within in another View and used (it needs to
be done like this). What i need to do is to be able to vary the
records in the nested query by specifying dates. These would somehow
need to be passed to the nested query.

I've looked into stored procedures/functions but am still stumped on
how to do this.

Can anyone help?


Without your view definitions, it's not possible to give a good answer, but
in general most views can be re-written as table-valued functions:

create view dbo.MyView
as
select DateColumn, col1, col2
from dbo.MyTable

select * from dbo.MyView where DateColumn between '20040101' and '20040131'

becomes

create function dbo.MyFunc (@date1 datetime, @date2 datetime)
returns table
as
return (
select DateColumn, col1, col2
from dbo.MyTable
where DateColumn between @date1 and @date2
)

select * from dbo.MyFunc('20040101', '20040131')

Functions can also be nested, if necessary. If this doesn't help, perhaps
you could post (simplified) view definitions (CREATE VIEW statements), and
someone may be able to help.

Simon
Jul 20 '05 #2

P: n/a
VIEWS do not take parameters. You will probably have to write it out
as one statement without views in a stored procedure. We can nly gues
without seeing the actual code, of course.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.