Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Merge data from 2 views

Author  Topic 

kiddoOnSQL
Starting Member

16 Posts

Posted - 2010-05-10 : 03:45:27
hello

I have 2 views whose data is derived from 2 seperate tables.
View 1 has the foll columns:

Code
Qualifications

View 2 has the foll columns:

Code
Software Known

Now I need to create 3rd view called Skills, which essentially has to combine the values in the Qualifications column of view 1 and Software Known column of view 2, INTO the 'Skills Acquired' column of View 3.
View 3 will also have the column 'Code' which is a common link between all 3 views.

Is this this possible?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-10 : 04:05:48
create view view3
as
select v1.code,v1.Qualifications+' '+v2.[Software Known] from view1 as v1 inner join view2 as v2
on v1.code=v2.code

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-10 : 13:16:34
[code]create view view3
as
select v1.code,coalesce(v1.Qualifications,'')+ coalesce(' '+v2.[Software Known],'') from view1 as v1 inner join view2 as v2
on v1.code=v2.code
[/code]

if columns are nullable

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kiddoOnSQL
Starting Member

16 Posts

Posted - 2010-05-10 : 20:06:40
Thanks guys, it worked. I just had to make one change, ie specifiy a column name after concatenating qualifications + software known:

create view view3
as
select v1.code,v1.Qualifications+' '+v2.[Software Known] AS SKILL from view1 as v1 inner join view2 as v2
on v1.code=v2.code
Go to Top of Page
   

- Advertisement -