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

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.