![]() |
inserting commas in number SQL |
1. First lets create a table or simply decleare it as
CREATE TABLE Table_1(COLUMN_1 NVARCHAR(20), COLUMN_2 NVARCHAR (20))
INSERT INTO Table_1 VALUES(1230000000.45,3250000000.87)
Now we have the table T1 as:
COLUMN_1 COLUMN_2
1230000000.45 3250000000.87
2. USE THE QUERY BELOW
CORRECT QUERY:
SELECT (select convert(varchar,cast(COLUMN_1 as money),1)) FROM Table_1
This will give 1,230,000,000.45
SELECT PARSENAME((select convert(varchar,cast(COLUMN_2 as money),1)), 2) FROM Table_1
This will give 3,250,000,000
It can also be done by a select statement as:
SELECT PARSENAME((select convert(varchar,cast(10000000 as money),1)), 2)
10,000,000
No comments:
Post a Comment