Can we pass parameters to a view in SQL?

前端 未结 20 2373
庸人自扰
庸人自扰 2020-11-29 18:29

Can we pass a parameter to a view in Microsoft SQL Server?

I tried to create view in the following way, but it doesn\'t work:

create o         


        
20条回答
  •  伪装坚强ぢ
    2020-11-29 18:59

    I have an idea that I haven't tried yet. You can do:

    CREATE VIEW updated_customers AS
    SELECT * FROM customer as aa
    LEFT JOIN customer_rec as bb
    ON aa.id = bb.customer_id
    WHERE aa.updated_at between (SELECT start_date FROM config WHERE active = 1) 
    and (SELECT end_date FROM config WHERE active = 1)
    

    Your parameters will be saved and changed in the Config table.

提交回复
热议问题