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)
 Query

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2012-12-19 : 05:54:55
Hi

select t0.name 'Name' , t1.u_amount 'Amount' from [@temp] t0 left join [@temp1] t1 on t0.code = t1.u_al_code where t1.u_id = @id

I want all records to be displayed from [@temp] whether corresponding records exist in [@temp1] table or not. Currenlt it is displaying only those records which exist in both tables.

Thanks

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-12-19 : 06:42:47

t0.code = t1.u_al_code AND t1.u_id = @id



--
Chandu
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-12-19 : 06:43:17
select t0.name 'Name' , t1.u_amount 'Amount' from [@temp] t0 left join [@temp1] t1 on t0.code = t1.u_al_code and t1.u_id = @id

Not sure that is what you want though.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-19 : 08:11:01
reason is this

http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/criteria-on-outer-joined-tables.aspx

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

Go to Top of Page

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2012-12-19 : 09:55:02
Dear All

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-19 : 09:56:30
welcome

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

Go to Top of Page
   

- Advertisement -