[MS-SQL] DTS - Query문으로 사용하기

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/06/24 14:50 2008/06/24 14:50
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3396

[MS-SQL] CONCAT - 문자열 합치기

Mysql 에서는 기호로 문자열 합치기를 할수 없고, 함수를 사용한다.


CONCAT

select CONCAT(문자1 , 문자1) from 테이블명
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/05/21 11:52 2008/05/21 11:52
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3277

-- 데이터베이스의 사용자 테이블을 호출
--select * from sysobjects where xtype='U' order by name

-- 데이터베이스의 사용자 테이블 중 특정 필드가 있는 테이블만 호출한다.
select tbl.name, col.name colnm
from (
select id,
name
from sysobjects
where xtype = 'U'
--and name = 'tblBBS_DTQNA'
and name in ( select name from sysobjects where xtype='U' )
) tbl

inner join syscolumns col on col.id = tbl.id
left outer join sysindexkeys idx on idx.id = col.id and col.colid = idx.colid and indid = 1

where col.name in ( 'dtPubDate' )
order by tbl.name
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/04/18 20:41 2008/04/18 20:41
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3185

MSSQL 쿼리 결과창 닫는 단축키

MSSQL 쿼리 결과창 닫는 단축키


ctl + R


그러면, 쿼리 결과창이 닫힌다.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/04/18 11:23 2008/04/18 11:23
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3184

날짜 자릿수 나오게 하기 4 -> 04

datename(day,getDate()) 하면 1월 1일인 경우

01 이 나올줄 알았는데 그냥 1이 나오는군요. 이거 01로 나오게 하고 싶은데 어떻게 해야 되나.

select right('0' + cast(datename(day, '20070101') as varchar) , 2)
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/04/16 11:36 2008/04/16 11:36
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3177

MS-SQL - 숫자에 대한 연산자

MS-SQL - 숫자에 대한 연산자

형식 : + - * / % ( )

우선순위 : ( ) + - * / %
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/04/03 17:03 2008/04/03 17:03
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3130

MysqlYog - 사이트 소개, 설치방법

[DOWNLOAD]

1. mysql GUI tool
2. mssql 2 mysql ( migration 마이그레이션 )


http://www.webyog.com/






크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/04/01 11:50 2008/04/01 11:50
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3118

-- 나이별 주문 내용 통계 구하기
: count 보다는 sum 을 이용하는게 좋다.

SELECT
CONVERT(varchar(10),regDate,112) AS regDate,
COUNT(*) total,
COUNT(CASE maxOrderText WHEN 1 THEN maxOrderText ELSE null END) men,
COUNT(CASE maxOrderText WHEN 0 THEN maxOrderText ELSE null END) women,
sum(CASE WHEN maxOrder < 10 THEN 1 ELSE 0 END) age00,
sum(CASE WHEN maxOrder between 10 and 20 THEN 1 ELSE 0 END) age10,
sum(CASE WHEN maxOrder between 20 and 30 THEN 1 ELSE 0 END) age20,
sum(CASE WHEN maxOrder between 30 and 40 THEN 1 ELSE 0 END) age30,
sum(CASE WHEN maxOrder > 40 THEN 1 ELSE 0 END) age40
/*
(SELECT COUNT(*) FROM tblshopgoods WHERE maxOrder < 10 ) as age00,
(SELECT COUNT(*) FROM tblshopgoods WHERE maxOrder between 10 and 20) as age10,
(SELECT COUNT(*) FROM tblshopgoods WHERE maxOrder between 20 and 30) as age20,
(SELECT COUNT(*) FROM tblshopgoods WHERE maxOrder between 30 and 40) as age30,
(SELECT COUNT(*) FROM tblshopgoods WHERE maxOrder > 40) as age40
*/
FROM dbo.tblShopGoods
GROUP BY CONVERT(varchar(10),regDate,112)
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/03/26 10:34 2008/03/26 10:34
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/3101

-- 문자열 구분자 분할 및 분할된 배열 갯수만큼 반복



declare @tstr varchar(100)
, @i int
, @tsql varchar(5000)
, @k int

create table #tbTemp
(aa varchar(50))

set @k = 1
while exists (select aa from tempTb where idx = @k)
Begin
select @tstr=aa from tempTb where idx = @k
select @i = charindex('||', @tstr)
if @i > 0
begin
while @i > 0
begin
insert into #tbTemp values(left(@tstr, charIndex('||', @tstr)-1))
select @tstr = substring(@tstr, charindex('||', @tstr) + 2, len(@tstr))
select @i = charindex('||' , @tstr)
end
select @tsql = left(@tsql, len(@tsql)-2)
insert into #tbTemp values (@tstr)
end
else
insert into #tbTemp values(@tstr)

set @k = @k + 1
End

select aa, count(aa) as cnt from #tbTemp
group by aa
order by aa

drop table #tbTemp
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2008/01/28 17:41 2008/01/28 17:41
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/2954

select
'9500',
substring(convert(varchar(18), cast('9500' as money), 1), 1, charindex('.', convert(varchar(18), cast('9500' as money), 1))-1)



CONVERT 사용

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )



다음 표에서 왼쪽 열은 money 또는 smallmoney를 문자 데이터로 변환하기 위한 style 값을 나타냅니다.

0(기본값)
- 소수점 왼쪽의 세 자릿수마다 쉼표를 사용하지 않으며, 소수점 오른쪽에 두 자리가 나타납니다(예: 4235.98).

1
- 소수점 왼쪽의 세 자릿수마다 쉼표를 사용하며, 소수점 오른쪽에 두 자리가 나타납니다(예: 3,510.92).

2
- 소수점 왼쪽의 세 자릿수마다 쉼표를 사용하지 않으며, 소수점 오른쪽에 네 자리가 나타납니다(예: 4235.9819).
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2007/10/25 17:02 2007/10/25 17:02
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/2743

« Previous : 1 : ... 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10 : 11 : ... 12 : Next »

블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Statistics Graph

Site Stats

Total hits:
186183
Today:
441
Yesterday:
745