"Hugo Kornelis" wrote:
> On Fri, 20 Jan 2006 07:36:05 -0800, Xavier wrote:
>
> >I know it can be done with a SP but is there a way to prompt a user for
> >specific criteria like date range (between ? and ?) in a view.
> >I have a query in a view but I need to prompt the user for a date range, my
> >front end is access 2002 I can do it as a passthrough but it takes to long to
> >run and while testing I found that as a view it runs in half the time.
>
> Hi Xavier,
>
> SQL Server can't ever prompt the user. Not in a view, and not in a
> stored procedure either.
>
> If you refer to prompting for arguments in the front end, then passing
> them as parameters to the back end: that is possible in stored procs,
> but not in a view. But you can use variables in a SELECT statement that
> queries a view.
>
> However, I am intrigued by your statement that you found a view to be
> faster than a stored procedure. While I don't doubt your observations,
> I'm pretty sure that there's no such blanket statement about performance
> of views vs stored procedures. I suspect that is has something to do
> with the specific details of your tables, your stored procedure and your
> view.
>
> To investigate this further, you'll have to give more details: how do
> your tables look (CREATE TABLE statements), how are the view and the
> stored procedure defined (CREATE VIEW / CREATE PROC), what does your
> data typically look like (INSERT statements for a small sample of your
> data) and how do you call the view and the stored proc?
>
> Chcek out
www.aspfaq.com/5006 for some tips on how to assemble this
> information.
>
> --
> Hugo Kornelis, SQL Server MVP