isnumeric

02/05/2007 - 15:03 por etragu | Informe spam
hola
alguien me puede explicar esto?

select isnumeric('0007678,03') da 1 verdadero
select isnumeric('00011,00') da 0 falso!!!!

no entiendo la diferencia
gracias

Preguntas similare

Leer las respuestas

#6 Rubén Vigón
02/05/2007 - 18:03 | Informe spam
Un asunto realmente curioso...
Lo he preguntado en el foro privado de SQL Server y el "monstruo" Steve Kass me lo ha aclarado; ahí os va su respuesta:
_________________________________________

Rubén,

For unknown reasons, in SQL Server 2000, only certain numbers of digits were allowed before the leftmost comma of a string in order for it to be convertible
to [money]. Specifically, there had to be exactly 0, 1, 2, 3, or 7 digits before the leftmost comma

http://groups.google.com/group/micr...c6231b5a14

This restriction has apparently been removed in SQL Server 2005, and any number of digits is allowed before the comma so long as overflow doesn't occur. Nice of you to have noticed this!

It's worth pointing out that the comma is ignored in the conversion to money, and it is never treated as a "decimal point," despite regional conventions in much of the world

declare @t table (
n int
)
insert into @t values (0) insert into @t values (1)
insert into @t values (2) insert into @t values (3)
insert into @t values (4) insert into @t values (5)
insert into @t values (6) insert into @t values (7)
insert into @t values (8) insert into @t values (9)
insert into @t values (10) insert into @t values (11)
insert into @t values (12)

select
cast(quotename(T1.n)+','+quotename(T2.n) as varchar(14)) as [[left]],[right]]],
isnumeric(replicate('1',T1.n) + ',' + replicate('1',T2.n)) as [isnumeric], replicate('1',T1.n) + ',' + replicate('1',T2.n) as [string]
from
@t as T1
cross join @t as T2
where
T1.n + T2.n <= len('922337203685477')
_________________________________________

Un saludo!

Rubén Vigón
Microsoft MVP Visual Basic
http://vigon.mvps.org
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida