돈 형식으로 출력하기 쿼리 (간단)
SQL / 2009. 1. 20. 18:52
-- 데이터 타입이 int 형 일때
CREATE TABLE [dbo].[gogogo](
[n] [varchar](10) COLLATE Latin1_General_CS_AS NULL,
[m] [int] NULL
)
insert into gogogo values('aaaaaa',111211)
insert into gogogo values('acccaa',11333111)
insert into gogogo values('adddaa',11444111)
insert into gogogo values('aaggga',11155511)
insert into gogogo values('ahhhaa',11166611)
-- money 형식으로 바꾸고 형변환
select n,convert(varchar(20), convert(money,m),1) as m from gogogo
-- 데이터 타입이 money 일때
create table tb_money(seq int identity, col1 money)
go
insert into tb_money(col1) values(1000)
insert into tb_money(col1) values(2000)
insert into tb_money(col1) values(3000)
go
select seq, convert(varchar(10), col1, 1) from tb_money
go
끝.