_대문 | 방명록 | 최근글 | 홈피소개 | 주인놈 |
FrontPage › isnumeric함수
|
|
숫자인지 아닌지 알아볼 때에 isnumeric() 함수를 사용하고는 한다. 근데 100% 다 걸러주는 것은 아니다. 다음과 같은 경우다. (ascii 코드로 문자인 것들이 숫자로 반환된다.)
select [ascii code] = str(number) , [ascii character] = char(number) , [isnumeric returns] = isnumeric(char(number)) from master.dbo.spt_values where type = 'p' and number between 0 and 255 and isnumeric(char(number)) = 1 어떻게 하면 되나? like 패턴매칭을 이용하면 된다.
select [ascii code] = str(number) , [ascii character] = char(number) , [isnumeric returns] = case when str(number) like '%[^0-9]%' then 0 else 1 end from master.dbo.spt_values where type = 'p' and number between 0 and 255 and isnumeric(char(number)) = 1
|
돈을 잃은 건 잃은 게 아니다. 명예를 잃은 건 조금 잃은 것이다. 용기를 잃은 건 모두 잃은 것이다. |