English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i am having troubls specially in TO_NUMBER to char function

2006-11-07 18:31:49 · 3 answers · asked by zain86us 2 in Computers & Internet Programming & Design

3 answers

TO_NUMBER: converts a character value expressing a number to a number datatype.

Syntax:
TO_NUMBER(char)

Example:
UPDATE SET salary = salary + TO_NUMBER(SUBSTR('$100',2,3));

Output:
10 rows updated.
____________________________________-
TO_CHAR: converts a value of a number datatype to a character datatype, using the optional format string. TO_CHAR() accepts a number(n) and a numeric format(fmt) in which the number has to appear. If fmt is omitted, 'n' is converted to a char value exactly long enough to hold all significant digits.

Syntax:
TO_CHAR (n[,fmt])

Example:
SELECT TO_CHAR(17145,'$099,999') "Char" FROM DUAL;

Output:
Char
- - - - - - - - - - - -
$017,145

[Look, I've given u the examples from my previously done queries, if u find any difficulty, u can mail me].

2006-11-11 16:48:49 · answer #1 · answered by Innocence Redefined 5 · 0 0

declare @numeric as int
declare @varchar as varchar(50)

set @numeric=23

--to convert number to varchar

select @varchar=
convert(varchar(50),@numeric)


-- to convert varchar to numeric need another step to validate the varchar


select @numeric=convert(int,@varchar)

2006-11-08 03:17:04 · answer #2 · answered by safrodin 3 · 1 0

declare @variable as int
set @variable = 5
SELECT CONVERT(char, @variable)
???
I am not to sure of your question

2006-11-08 03:01:58 · answer #3 · answered by Instinct_Chick 2 · 1 0

fedest.com, questions and answers