snp.it
snp.it

Reputation: 522

Insert a value/Row in a View

I have a view which have like 4 Values,


   Element No        Details     UniqueID
         1           Alpha          2000
         2           Beta           2001
         3           Zeta           2002
         4           Gamma          2003

This is a view, and I am trying to insert another value at run time; on top of which I am gonna create another View.


   Element No        Details     UniqueID
         0           Pie            1000
         1           Alpha          2000
         2           Beta           2001
         3           Zeta           2002
         4           Gamma          2003

EDIT:

I have to add a value to the table with element No: 0 . The initial table is obtained when I run a view1. I am trying to create another view2 by using the present view1 and couple of other View and Tables. So i need to insert the above value into View1 to obtain my required value

Upvotes: 1

Views: 58

Answers (1)

Robert
Robert

Reputation: 25753

Try this way:

create view yourview2
as
select 0 as "Element No", 'Pie' as Details , 1000 as UniqueID
union all 
select [Element No], Details, UniqueID
from yourview

NOTE: union all doesn't remove duplicates

Upvotes: 3

Related Questions