Can we pass parameters to a view in SQL?

前端 未结 20 2301
庸人自扰
庸人自扰 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:50

    A view is nothing more than a predifined 'SELECT' statement. So the only real answer would be: No, you cannot.

    I think what you really want to do is create a stored procedure, where in principle you can use any valid SQL to do whatever you want, including accept parameters and select data.

    It seems likely that you really only need to add a where clause when you select from your view though, but you didn't really provide enough details to be sure.

提交回复
热议问题