Re: Weird Cast operator
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 09/13/04
- Next message: Zach Wells: "Re: what's wrong w/ my queries?"
- Previous message: Anith Sen: "Re: Weird Cast operator"
- In reply to: Ganesan Rajaraman: "Weird Cast operator"
- Next in thread: Ganesan Rajaraman: "Re: Weird Cast operator"
- Reply: Ganesan Rajaraman: "Re: Weird Cast operator"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 13 Sep 2004 20:38:06 +0100
CASE can only return a single datatype. In your second CASE one expression
is INT and the other VARCHAR. The rules of datatype precedence give INTEGER
a higher priority than VARCHAR so SQL attempts to convert the string to a
numeric, which causes an error.
Change the second CASE expression to:
...
THEN CAST(CAST(@in AS INT) AS VARCHAR(6))
...
-- David Portas SQL Server MVP --
- Next message: Zach Wells: "Re: what's wrong w/ my queries?"
- Previous message: Anith Sen: "Re: Weird Cast operator"
- In reply to: Ganesan Rajaraman: "Weird Cast operator"
- Next in thread: Ganesan Rajaraman: "Re: Weird Cast operator"
- Reply: Ganesan Rajaraman: "Re: Weird Cast operator"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|