I have a datatable like, as below. I have created a multiple views with different logic based on ID numbers.
Can anyone please tell me: is it possible to have a stored procedure which will execute a view based on the id available in table?
In this example: ID 1001 has a different view, and ID 1002 have yet another.
The table will have data for a specific ID at a given point of time.
and will get truncated before loading data with different ID.
declare @table table
sales numeric (10,2),
select 1001 , 25000,'2005-05-01' union all
select 1001,256565,'2006-10-01' union all
select 1002 , 55000,'2005-10-11' union all
select 1002,56565,'2006-11-21 '
Do you need something like this?:
If @id = 1001 SELECT * FROM VIEW_1 If @id = 1002 SELECT * FROM VIEW_2