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.
Author |
Topic |
stuckne1
Starting Member
22 Posts |
Posted - 2010-10-08 : 11:47:22
|
Hi, I'm trying to replace the null values in the results query with a '0' for Order_Id. This is what I have so far but every time I go past this point it doesn't work... SELECT CUSTOMER_t.Customer_Name, CUSTOMER_t.Customer_Id, Order_IdFROM CUSTOMER_t LEFT OUTER JOIN ORDER_t ON CUSTOMER_t.Customer_Id = ORDER_t.CUSTOMER_Id |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-08 : 11:49:07
|
isnull(Order_Id,'0') as Order_Id No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-08 : 11:49:54
|
Use ISNULL or COLAESCESELECT CUSTOMER_t.Customer_Name, CUSTOMER_t.Customer_Id, ISNULL(Order_Id, 0) AS [Order_Id]FROM CUSTOMER_t LEFT OUTER JOIN ORDER_t ON CUSTOMER_t.Customer_Id = ORDER_t.CUSTOMER_Id Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2010-10-08 : 16:03:40
|
Look up COALESCE(); it isw ANSI/ISO Standard. Do not use the proprietary ISNULL(); they are not the same--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-08 : 16:57:53
|
No, not the same, but there's no reason not to use isnull unless you're planning on porting everything to a different platform.As with all code, it becomes proprietary as soon as developers start writing it for their applications. |
|
|
stuckne1
Starting Member
22 Posts |
Posted - 2010-10-09 : 22:15:48
|
Alright, thanks guys! |
|
|
|
|
|
|
|