Materialized Views or Table Functions or any other way to optimise query

SQL Server 2005:

I designed 5 stored procedures which almost use same join condition but parameters or values in where clause change for each on different runs.
Is it best solution to create a view with all join conditions without where clause and then query from view or work on view?
Can views auto update itself if i create view?
Can i do sub-queries or query similar to (i think i read somewhere views do not support sub queries but not 100% sure)

In my queries i use joins similar to code attached

 i'm using join twice and for each stored procedure difference is only in where clause ( i add new 'And' conditions) so i thought can i reduce it using some views
select c1,c2,c3
FROM [[join conditions - 5 tables]]
Inner join
select x1,x2,x3, some case statements
FROM [[join conditions - 5 tables]]
where t1.s1 = val1 and t2.s2 = v2 etc
) s
on = id

Open in new window

Who is Participating?
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
yes, you could reduce the code by the views, but the performance might eventually not be the best.
you must check this by testing
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.

All Courses

From novice to tech pro — start learning today.