Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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