0 votes
1 view
in SQL by (20.3k points)

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;

1 Answer

0 votes
by (40.3k points)

You can implement the stored function, like this:

CREATE FUNCTION v_emp (@pintEno INT)




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)

Welcome to Intellipaat Community. Get your technical queries answered by top developers !