• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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