Can we pass a parameter to a view in Microsoft SQL Server?
I tried to create a view in the following way, but it doesn't work:
create or replace view v_emp(eno number) as select * from emp where emp_id=&eno;
You can implement the stored function, like this:
CREATE FUNCTION v_emp (@pintEno INT)RETURNS TABLEASRETURNSELECT * FROM emp WHERE [email protected];
CREATE FUNCTION v_emp (@pintEno INT)
RETURNS TABLE
AS
RETURN
SELECT * FROM emp WHERE [email protected];
This will allow you to use it as the normal view, by using the below code:
SELECT * FROM v_emp(10)