SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sunny_10
Yak Posting Veteran

65 Posts

Posted - 12/19/2012 :  05:54:55  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2218 Posts

Posted - 12/19/2012 :  06:42:47  Show Profile  Reply with Quote

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



--
Chandu
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/19/2012 :  06:43:17  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

India
52317 Posts

Posted - 12/19/2012 :  08:11:01  Show Profile  Reply with Quote
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

65 Posts

Posted - 12/19/2012 :  09:55:02  Show Profile  Reply with Quote
Dear All

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/19/2012 :  09:56:30  Show Profile  Reply with Quote
welcome

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000