我有以下问题:我想创建等包含一个表,其列“verylongtext”应该在一定不能超过50个字符的字符串被分裂的看法。 此结果集应该在视图中接合。 临时表将创建下列方式:解决办法临时表中查看SQL Server的
create table #results(id int, string varchar(400))
declare @results table(id int, string varchar(400))
declare @id int
declare @strings varchar(400)
set @id = 0
while exists (select * from roottable where row_id > @id)
begin
select top 1 @id = row_id, @strings = verylongtext from roottable
where row_id > @id
order by row_id asc
insert into #results
select @id, data from dbo.Split([dbo].[DelineateEachNth](@strings, 50, '$'), '$')
end
问题是当然的,没有临时表允许的看法。 CTE似乎不适用于该函数的结果集。有没有其他可行的方法?我绝对无能为力。提前致谢!!
你可能并不需要为您的要求while循环...这是糟糕的设计的...你可能需要直接选择查询,您可以在视图中直接安装.. –
请放在一起[SQL小提琴] (http://sqlfiddle.com),以便人们可以合作。 – Lucero