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 2008 Forums
 Transact-SQL (2008)
 If no record set to 0
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Zath
Constraint Violating Yak Guru

USA
255 Posts

Posted - 05/22/2012 :  12:16:15  Show Profile  Visit Zath's Homepage  Reply with Quote

Most of the time, there will be no record in the LEFT OUTER JOIN BELOW

SELECT 
  tbl1.Name,
tblJOIN.Code		

FROM MyTable tbl1
LEFT OUTER JOIN MyJoinTable tblJOIN on tblJOIN.ID = tbl1.ID


So, if tblJOIN.Code comes back empty or null, set it to 0.

Just can't seem to get the syntax right to set it to 0.

Thanks!!!

jimf
Flowing Fount of Yak Knowledge

USA
2866 Posts

Posted - 05/22/2012 :  12:17:55  Show Profile  Reply with Quote
SELECT
tbl1.Name,
ISNULL(tblJOIN.Code,0)

FROM MyTable tbl1
LEFT OUTER JOIN MyJoinTable tblJOIN on tblJOIN.ID = tbl1.ID

Jim

Everyday I learn something that somebody else already knew
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.03 seconds. Powered By: Snitz Forums 2000