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 2000 Forums
 SQL Server Development (2000)
 how can i get the record from both the table

Author  Topic 

Sarakumar
Posting Yak Master

108 Posts

Posted - 2006-06-28 : 03:53:25
Hai, i have two tables, both the tables has got only one column called sid to join. But sometimes, the first table maynot have record and sometimes second table maynot have any record.
But whatever the situation , i want to join both the table and need to get the Value..
i tried full outer join also...but im not getting the Expected file


DECLARE @ACTUALCNT TABLE
(
PPTCNT INT,
COMPANYNAME VARCHAR(100)
)
insert into @ACTUALCNT select from .....
DECLARE @RESERVEDCNT TABLE
(
PPTCNT INT,
COMPANYNAME VARCHAR(100)
)
insert into @reservedcnt select something from somewhere


SELECT A.COMPANYNAME ,
isnull(A.PPTCNT,0) ,
ISNULL(B.PPTCNT,0)
FROM @ACTUALCNT A
LEFT OUTER JOIN @RESERVEDCNT B
ON A.COMPANYNAME = B.COMPANYNAME

Advise pls

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-28 : 03:57:29
What you need is LEFT JOIN or FULL OUTER JOIN.

"but im not getting the Expected file "
Maybe you can post some sample data and result that you want.



KH

Go to Top of Page
   

- Advertisement -