日期:2014-05-18  浏览次数:20536 次

求一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