Skip to main content

Sql Server view example

These are some examples creating view from a table

create view prodlist (prid,prname,tam)
as
select prodid, prodname, totalamount
from products


select * from prodlist

displays view's sql text:
exec sp_helptext 'prodlist'

to encrypt view's sql text:
alter view prodlist (prid,prname,tam,)
with encryption
as
select prodid, prodname, totalamount
from products


select * from prodlist


to create view from another view:
create view specificprod
as
select * from prodlist
where prodname='your_prod_name'


select * from specificprod


to drop view:
drop view specificprod

Comments

Popular posts from this blog