Re: SQL Comparison of ISNULL values
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 07/15/04
- Next message: Zach Wells: "Re: Summing last 6 months..."
- Previous message: Chris: "Re: Query taking 1.5 hr and still going"
- In reply to: Dan Williams: "SQL Comparison of ISNULL values"
- Next in thread: Dan Williams: "Re: SQL Comparison of ISNULL values"
- Reply: Dan Williams: "Re: SQL Comparison of ISNULL values"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 15 Jul 2004 12:23:34 -0400
Can you show the exact results you want?
Given this data:
CREATE TABLE table1
(
ID INT,
number INT
)
GO
CREATE TABLE table2
(
ID INT,
number INT
)
GO
SET NOCOUNT ON
INSERT table1 SELECT 1, 1
INSERT table1 SELECT 2, NULL
INSERT table1 SELECT 3, 5
INSERT table1 SELECT 4, 12
INSERT table1 SELECT 6, NULL
INSERT table2 SELECT 1, 5
INSERT table2 SELECT 3, NULL
INSERT table2 SELECT 4, 15
INSERT table2 SELECT 5, 12
INSERT table2 SELECT 6, NULL
Resultset:
???
-- http://www.aspfaq.com/ (Reverse address to reply.) "Dan Williams" <dan_williams@newcross-nursing.com> wrote in message news:2eac5d02.0407150814.21685cab@posting.google.com... > I'm attempting the following SQL query:- > > > SELECT table1.id from table1 left outer join table2 > on table1.id = table2.id > where ISNULL(table1.number,0) <> ISNULL(table2.number,0) > > But the damn thing won't work when either of the tables contain NULL > values. > > How do i go about comparing two values even if one of them contains a > NULL value? And i'd rather not have to create a huge query string!! > > Many thanks > > Dan Williams.
- Next message: Zach Wells: "Re: Summing last 6 months..."
- Previous message: Chris: "Re: Query taking 1.5 hr and still going"
- In reply to: Dan Williams: "SQL Comparison of ISNULL values"
- Next in thread: Dan Williams: "Re: SQL Comparison of ISNULL values"
- Reply: Dan Williams: "Re: SQL Comparison of ISNULL values"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|