I have a strange problem that I need help troubleshooting. I have the
 following statement in a stored procedure:
 SELECT IsNull(NullIf(Convert(varchar(20), Cast(Value AS datetime), 126), ''),
 '')
 FROM #TFieldValues TFV
 WHERE TFV.DataType = 'Date'
 When this statement is run, it returns the following error;
 Msg 241, Level 16, State 1, Procedure <the name of my procedure>, Line 142
 Conversion failed when converting datetime from character string.
 The field #TFieldValues.Value is created as varchar(2000).
 So, I run the following statement, and 21 rows are returned, where 8 are date
 values and 13 are empty strings:
 SELECT Value FROM #TFieldValues WHERE DataType = 'Date'
 The 8 date values returned are the following:
 2/23/2006
 03/21/2006
 08/23/2006
 1O/18/2OO5
 1O/18/2OO5
 1O/18/2OO5
 02/26/2007
 02/26/2007
 I then run the following statement
 SELECT
 TFV.Value
 FROM #TFieldValues TFV
 WHERE
 CASE
 WHEN ISDATE(Value) = 0 THEN 0
 WHEN ISDATE(Value) = 1 THEN 1
 END = 1
 AND TFV.DataType = 'Date'
 Instead of 8 date values being returned, I only return 5, which are the
 following:
 2/23/2006
 03/21/2006
 08/23/2006
 02/26/2007
 02/26/2007
 In just looking at the returns in the grid in Management Studio, when I run
 the select statement that returned the 8 date values, it appears the
 1O/18/2OO5 values are of a different font size. This can probably even be
 seen as you compare the zero's from the following paste:
 08/23/2006
 1O/18/2OO5
 Any ideas on validation, or handling this situation?
 --
 Message posted via SQLMonster.com
 http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200703/1"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:6f39ac268793b@.uwe...
>I have a strange problem that I need help troubleshooting. I have the
> following statement in a stored procedure:
> SELECT IsNull(NullIf(Convert(varchar(20), Cast(Value AS datetime), 126),
> ''),
> '')
> FROM #TFieldValues TFV
> WHERE TFV.DataType = 'Date'
> When this statement is run, it returns the following error;
> Msg 241, Level 16, State 1, Procedure <the name of my procedure>, Line 142
> Conversion failed when converting datetime from character string.
> The field #TFieldValues.Value is created as varchar(2000).
> So, I run the following statement, and 21 rows are returned, where 8 are
> date
> values and 13 are empty strings:
> SELECT Value FROM #TFieldValues WHERE DataType = 'Date'
> The 8 date values returned are the following:
> 2/23/2006
> 03/21/2006
> 08/23/2006
> 1O/18/2OO5
> 1O/18/2OO5
> 1O/18/2OO5
> 02/26/2007
> 02/26/2007
> I then run the following statement
> SELECT
> TFV.Value
> FROM #TFieldValues TFV
> WHERE
> CASE
> WHEN ISDATE(Value) = 0 THEN 0
> WHEN ISDATE(Value) = 1 THEN 1
> END = 1
> AND TFV.DataType = 'Date'
> Instead of 8 date values being returned, I only return 5, which are the
> following:
> 2/23/2006
> 03/21/2006
> 08/23/2006
> 02/26/2007
> 02/26/2007
> In just looking at the returns in the grid in Management Studio, when I
> run
> the select statement that returned the 8 date values, it appears the
> 1O/18/2OO5 values are of a different font size. This can probably even be
> seen as you compare the zero's from the following paste:
> 08/23/2006
> 1O/18/2OO5
No - it isn't a font issue. These are capital O characters, not zeros.
Switch to a font that uses slashed zeros and you will more clearly see this.
Consider this one of the "advantages" to using the EAV data model - store
anythingsqlsql
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment