learning python learning python - 1 year ago 61
SQL Question

Call view from a stored procedure based on column value

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
id int,
sales numeric (10,2),
years date

insert @table

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 '


Answer Source

Do you need something like this?:

If @id = 1001 
If @id = 1002
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download