title: Workaround for temporary Table in view SQL Server
body: <p>I have the following problem: I want to create a view that contains among others a table, whose column 'verylongtext' should be split in strings that mustn't exceed 50 characters.
     this result set should be joined in the view. 
     the temporary table would be created the following way:</p>
  
  <pre><code>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 &gt; @id)
  begin
      select top 1 @id = row_id, @strings = verylongtext from roottable
      where row_id &gt; @id
      order by row_id asc
      insert into #results
      select @id, data from dbo.Split( [dbo].[DelineateEachNth](@strings, 50, '$'), '$')
  end   
  </code></pre>
  
  <p>The problem is of course, that no temporary tables are allowed in views. CTEs don't seem to work with the resultset of the function.  Is there any possible other way? I am absolutely clueless. Thanks in advance!!</p>