Convertir numero en letras ...
Como puedo convertir un numero en letras desde un procedimiento almacenado de SQL Server ????
Es muy facil solo tienes que utilizar cualquiera de las siquientes instrucciones:Convert o Cast, te paso el texto tal y como viene en la ayuda.
Syntax
Using CAST:
CAST ( expression AS data_type )
Using CONVERT:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Arguments
expression
Is any valid Microsoft® SQL Server™ expression. For more information, see Expressions.
data_type
Is the target system-supplied data type, including bigint and sql_variant. User-defined data types cannot be used. For more information about available data types, see Data Types.
length
Is an optional parameter of nchar, nvarchar, char, varchar, binary, or varbinary data types.
style
Is the style of date format used to convert datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types), or the string format when converting float, real, money, or smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types).
SQL Server supports the date format in Arabic style, using Kuwaiti algorithm.
In the table, the two columns on the left represent the style values for datetime or smalldatetime conversion to character data. Add 100 to a style value to get a four-place year that includes the century (yyyy).
lo cual quedaria asi
Cast(Tu_Numero as Varchar(Longitud_necesaria))
o
Convert(Varchar(Longitud_Necesaria), Tu_Numero)
Syntax
Using CAST:
CAST ( expression AS data_type )
Using CONVERT:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Arguments
expression
Is any valid Microsoft® SQL Server™ expression. For more information, see Expressions.
data_type
Is the target system-supplied data type, including bigint and sql_variant. User-defined data types cannot be used. For more information about available data types, see Data Types.
length
Is an optional parameter of nchar, nvarchar, char, varchar, binary, or varbinary data types.
style
Is the style of date format used to convert datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types), or the string format when converting float, real, money, or smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types).
SQL Server supports the date format in Arabic style, using Kuwaiti algorithm.
In the table, the two columns on the left represent the style values for datetime or smalldatetime conversion to character data. Add 100 to a style value to get a four-place year that includes the century (yyyy).
lo cual quedaria asi
Cast(Tu_Numero as Varchar(Longitud_necesaria))
o
Convert(Varchar(Longitud_Necesaria), Tu_Numero)
Tengo una duda
tu quieres convertir en numero
589
a
quinientos ochenta y nueve
o quieres convertir un numerico
a char o varchar
589 = '589'
Yo tengo un problema, ya que intento insertar en una tabla del SQL server un dato ke previamente he sacado de otra tabla, guardado en una variable de asp, por lo ke intento transformar el varchar de la variable de asp a float, ya que la tabla está como float, pero al hacerle un convert, el sql lee el valor decimal recogido como el style ...¿? a ver te pongo la consulta INSERT INTO ... VALUES (CONVERT(float,"&pmc&") ... ) entonces el "&pmc&" aparece como 321,23 y lel 23 lo trata como si fuera el style, le he puesto comillas simples pero no funciona \'"&pmc&"\'
qué puedo hacer ¿?¿?¿? gracias
qué puedo hacer ¿?¿?¿? gracias