3

这是我用来减少字符长度的查询。

这些是一些示例 char("有关可以是的有效 SQL Server 2005 数据类型的更多信息......是一个整数,它指定子字符串的开始位置。开始可以是 bigint 类型。")

如果我给子字符串以将长度固定为 15 。字符的其余部分应该像这样显示(...)

我的 sql 查询是这样的.....

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

例如:它应该像这样显示

For more information about the valid SQL Server 2005 data.
4

5 回答 5

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)+'.........' 
于 2012-11-07T09:10:42.657 回答
0

你是不是这个意思:

select Left('For more information about the valid SQL Server 2005 data', 15)+'...'

指定要显示的字符数作为系统定义函数 LEFT 的第二个参数。

于 2012-11-07T09:07:54.813 回答
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)+replicate('.', 25) 
from Admin 
于 2012-11-07T09:11:05.337 回答
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) 

+ '...' + 

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;
于 2012-11-07T09:12:09.843 回答
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 
于 2012-11-07T09:13:35.330 回答