2012-11-07 4 views
3

이것은 문자의 길이를 줄이기 위해 사용하는 쿼리입니다.부분 문자열 메서드의 SQL 쿼리

이러한 몇 가지 예를 들어 문자입니다 (이하 "될 수있는 유효한 SQL Server 2005의 데이터 유형 ...에 대한 자세한 내용은 문자열이 시작하는 위치를 지정하는 정수입니다. BIGINT 유형이 될 수 있습니다 시작합니다.")

길이를 15로 고정하기 위해 부분 문자열을 주면. 숯불의 나머지 부분은 예를 들어

select substring('For more information about the valid SQL Server 2005 data types that can be ... Is an integer that specifies where the substring starts. start can be of type bigint.',0,15) from Admin 

..... 내 SQL 쿼리가 이것이다

이런 식으로 (...)처럼 표시해야합니다 : 그것은이

For more information about the valid SQL Server 2005 data. 
+0

"나머지는 .... 같이 보일 것입니다."사실입니까, 아니면 문자열을 줄이려고합니까? ** 작동하지 않는 것은 무엇입니까? ** –

+0

대단히 고맙습니다 ... 그 작업 –

답변

2
select substring('For more information about the valid SQL Server 2005 data types that can be ... Is an integer that specifies where the substring starts. start can be of type bigint.',0,58)+'.........' 
0
같이 표시해야합니다
select Left('For more information about the valid SQL Server 2005 data', 15)+'...' 

문자의 수를 지정 시스템 정의 함수 왼쪽의 두 번째 매개 변수로 표시하기 :

당신은이를 의미했다.

0

이 같은 것을 사용할 수 있습니다 : 당신이 출력이 여기 그런 다음이

First_15_letters_ ... _Last_15_letters 

같은 싶은 경우

select substring('For more information about the valid SQL Server 2005 data types that can be ... Is an integer that specifies where the substring starts. start can be of type bigint.',0,15)+replicate('.', 25) 
from Admin 
0

그것을

select 
substring('For more information about the valid SQL Server 2005 data types that can be ... Is an integer that specifies where the substring starts. start can be of type bigint.',0,15) 

+ '...' + 

right('For more information about the valid SQL Server 2005 data types that can be ... Is an integer that specifies where the substring starts. start can be of type bigint.',15) 

from Admin; 
을 할 수있는 하나의 방법입니다
0
Please, not down from here : 
======================================================= 
    select substring('For more information about the valid SQL Server 2005 data types that 
    can be ... Is an integer that specifies where the substring starts. start can 
    be of type bigint.',0,15) 
--Not need "from Admin" 
=============================================================== 
select substring(colname,0,15) from Admin 
--"from Admin" Need when columnname is required