select view to view in sql
Posted on 2014-10-07
I have a select statement which was written awhile back. From VB code it calls ike this :
select *from vw_sample_1
Using cn As New OleDb.OleDbConnection(sConnString)
Dim cmd As New OleDb.OleDbCommand("select *from vw_sample_1", cn)
Dim r As OleDb.OleDbDataReader = cmd.ExecuteReader()
inside vw_sample_1 is
select *from vw_sample_1 s1
inner join vw_sample_2 s2
on s1.id = s2.id
select * from vw_sample_2
where startdate between DATEADD(day, -90, GETDATE()) and getdate()
Instead of setting a fixed of last 90 days, I want use variable instead. User can pass 30, 90, 60, etc.
Is there a way to pass a variable from vw_sample_1 to vw_sample_2 ?