NULL Date fields - Andrei |
05-Nov-07 02:12:49
|
Hi Terry,
You could try this :
select max(isnull(datea, '1900/01/01')) from #t1
You can replace '1900/01/01' with any small date, according to the dates you
have in your tables.
Andrei. |
 |
| |
NULL Date fields - Madhivana |
06-Nov-07 04:37:02
|
Why are worrying about warnings?
You can also use
select max(isnull(datea, '')) from #t1 |
 |
| |
NULL Date fields - Madhivanan |
06-Nov-07 04:49:42
|
On Nov 6, 2:37 pm, Madhivanan <Madhiva...@>
or
select id,max(isnull(datea, '')), sum(ISNULL(val,0)) as v from #t1
group by id |
 |
| |
NULL Date fields - terryshami |
06-Nov-07 05:55:13
|
Didn't think that would work - but I get
id df v
----------- ----------------------- -----------
1 2007-11-06 10:50:58.640 5
2 1900-01-01 00:00:00.000 13
its replaced empty string with first date of smalldatetime which I was
not expecting.
As previous poster said I could use max(ISNULL(datea, '18000101')) -
then update to NULL. This may
I'm worried about the warning because the App that uses this proposed
SP is a black box and will raise an error on warnings. |
 |
| |
NULL Date fields - Madhivanan |
07-Nov-07 08:02:14
|
Yes you can then replace 1900-01-01 00:00:00:000 with NULL when you
display at front end |
 |
| |
NULL Date fields - Hugo Kornelis |
07-Nov-07 06:04:04
|
Or do it in the back end:
SELECT id,
NULLIF(MAX(COALESCE(datea, '19000101')),'19000101'),
NULLIF(SUM(COALESCE(val,0)),0) AS v
FROM #t1
GROUP BY id;
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis |
 |
| |