SQLServerに大きな文字列があります。その文字列を10文字または15文字に切り捨てたい
元の文字列
this is test string. this is test string. this is test string. this is test string.
希望の文字列
this is test string. this is ......
SQLServerに大きな文字列があります。その文字列を10文字または15文字に切り捨てたい
元の文字列
this is test string. this is test string. this is test string. this is test string.
希望の文字列
this is test string. this is ......
長い文字列の数文字のみを返したい場合は、次を使用できます。
select
left(col, 15) + '...' col
from yourtable
SQL Fiddle with Demoを参照してください。
これにより、文字列の最初の 15 文字が返さ...
れ、最後に が連結されます。
15 未満の文字列が取得されないようにしたい場合は、...
次を使用できます。
select
case
when len(col)>15
then left(col, 15) + '...'
else col end col
from yourtable
デモで SQL Fiddle を参照してください
使用できます
LEFT(column, length)
また
SUBSTRING(column, start index, length)