Solved

Create View from Complex SQL query

Posted on 2006-11-10
4
336 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

856 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