RE: Casting in a where clause
From: The Ultimate Ozz (Ozz_at_discussions.microsoft.com)
Date: 11/19/04
- Next message: Imtiaz: "Re: Importing Chinese characters using DTS BulkInsert"
- Previous message: David Gugick: "Re: SQL Server 2000 registry values by edition?"
- In reply to: scottrg: "Casting in a where clause"
- Next in thread: Aaron [SQL Server MVP]: "Re: Casting in a where clause"
- Reply: Aaron [SQL Server MVP]: "Re: Casting in a where clause"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 19 Nov 2004 12:47:01 -0800
Looks like you never got the answer.
Here it should be:
where ISNUMERIC(ISNULL(static_mos,'-999')) = 1 and CAST(
isnull(static_mos, '-999') AS decimal(4,2)) = uservalue
From the pro....
- Azhar
"scottrg" wrote:
> I'm having trouble in a SQL statement that queries from a view that has
> non-numeric, null, and zero-length data in a varchar column. I'm trying to
> cast numeric data as a real number to compare against a user-entered value.
> Part of my SQL looks like:
>
> where ISNUMERIC(static_mos) = 1 and CAST(static_mos AS decimal(4,2)) =
> uservalue
>
> For some reason the CAST always takes precedence and the query blows up on
> null values. Aren't "and" clauses supposed to be evaluated left-to-right? Is
> there any way I can get the ISNUMERIC to be evaluated first?
>
- Next message: Imtiaz: "Re: Importing Chinese characters using DTS BulkInsert"
- Previous message: David Gugick: "Re: SQL Server 2000 registry values by edition?"
- In reply to: scottrg: "Casting in a where clause"
- Next in thread: Aaron [SQL Server MVP]: "Re: Casting in a where clause"
- Reply: Aaron [SQL Server MVP]: "Re: Casting in a where clause"
- Messages sorted by: [ date ] [ thread ]