Solved

Create View from Complex SQL query

Posted on 2006-11-10
4
330 Views
Last Modified: 2012-06-27
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
Comment
Question by:YLaw
4 Comments
 
LVL 11

Accepted Solution

by:
regbes earned 500 total points
ID: 17916980
Hi YLaw,

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

0
 

Author Comment

by:YLaw
ID: 17916985
Thanks.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17916988
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
 
LVL 29

Expert Comment

by:QPR
ID: 17917001
create procedure owner.spname
@variable datatype
as
paste here
Go
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question