• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

Create View from Complex SQL query

I have a complex sql query that I'd like to create a view for.  I went to views, create view and copied the query into it.  But it won't let me pass the @variable that I need there.  How do I do this?  Basically, whenever I use the view, I would have that parameter being passed in.

Thanks.
0
YLaw
Asked:
YLaw
1 Solution
 
regbesCommented:
Hi YLaw,

you will need to create a stored procedue or a tabled valued function as views do not support parameters

0
 
YLawAuthor Commented:
Thanks.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
YLaw,
>  How do I do this?
Views are nothing but virtual tables, you can't pass variables. You can either go for a function or a stored procedure
0
 
QPRCommented:
create procedure owner.spname
@variable datatype
as
paste here
Go
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now