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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 For Case Logic

Author  Topic 

smithi
Starting Member

2 Posts

Posted - 2010-08-05 : 22:05:32
I am having 2tables in same database with table A having colum1(F.K), date A ,PrincipleA,interest A with 2 rows in it and Table B is having Column1(p.k), column2, Date B ,PrincipleB and interestB with 3 rows . So the result table must get all Column2,Interest,principle,interest with all 5 rows.. from two tables it must all together have all princle interest and dates from two tables.... i am not able to use the union all b'coz i have to get column 2 as well from the table B
Do any one know how to get the data...

kenchee
Starting Member

49 Posts

Posted - 2010-08-05 : 22:56:37
Hi,
in your select on table A add a placeholder in your query i.e
select colum1, '' as column2, date A, PrincipleA, interest A from table A UNION ALL select Column1, column2, Date B ,PrincipleB, interestB from table b

is this what you're after?
Go to Top of Page

smithi
Starting Member

2 Posts

Posted - 2010-08-22 : 20:08:26
other than union is there any method to get the data..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-23 : 04:38:39
quote:
Originally posted by smithi

other than union is there any method to get the data..


why cant you use UNION? If you want contents from both tables as separate rows you should be using UNION (ALL)

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

Go to Top of Page
   

- Advertisement -