读书人

求一sql实现,该怎么解决

发布时间: 2012-01-09 21:05:42 作者: rapoo

求一sql实现
table表中的content字段值如果大于70个汉字(140个字符),刚分段取出,每一部分内容不大于70个汉字长度,存储过程得怎么写,谢谢

[解决办法]
比如350.

select substring(col,1,70) co1 from tb
union all
select substring(col,71,140) co1 from tb
union all
select substring(col,141,210) co1 from tb
union all
select substring(col,211,280) co1 from tb
union all
select substring(col,281,350) co1 from tb

[解决办法]
DECLARE @T TABLE
(
id int IDENTITY(1,1),
[content] varchar(8)
)
insert into @T
select '我是小狗 '
Union all
select 'Hello '
select id,SUBSTRING([content],1,2) from @T
Union all
select id,SUBSTRING([content],3,2) from @T
order by id desc

读书人网 >SQL Server

热点推荐