Convertir des lignes de text dans des loggings

Je cherche un moyen, que je peux convertir des lignes d'un text dans des dossiers séparés. Peut-être y a-t-il quelqu'un qui a une idée?

J'ai l'logging suivant dans un tableau:

1 blabla Messe\nJahr\nLand 

Le troisième champ est un champ de text. Le contenu est un text avec trois lignes.

maintenant, je devrais écrire un select, ce qui me donne à la suite trois loggings

 1 Memo 2 Jahr 3 Land 

Je suggère d'utiliser un slider, puis de split la string en utilisant charpos. comme je ne connaissais pas le nom de votre table ou colonne, j'ai utilisé le nom de la table a, le nom de la colonne a.

 declare c cursor for select a from a declare @p varchar(max) open c fetch next from c into @p; while @@FETCH_STATUS = 0 begin while CHARINDEX('\n',@p,0) > 0 begin select SUBSTRING(@p,0,charindex('\n',@p,0)) set @p = SUBSTRING(@p,charindex('\n',@p,0)+2, LEN(@p)-charindex('\n',@p,0)-1); end select @p; fetch next from c into @p; end DEALLOCATE c 

J'ai testé cela en utilisant

 create table a (a varchar(50)) insert into a values ('a\nb\nc') insert into a values ('d\ne\nf') 

utilisez ceci..

  ALTER FUNCTION [dbo].[GetWordsFromSsortingng] ( @ssortingng nvarchar(max) ) RETURNS @out TABLE ( Name nvarchar(200) ) AS BEGIN DECLARE @pos int, @nextpos int, @valuelen int SELECT @pos = 0, @nextpos = 1 WHILE @nextpos > 0 BEGIN SELECT @nextpos = charindex('\', @ssortingng, @pos + 1) SELECT @valuelen = CASE WHEN @nextpos > 0 THEN @nextpos ELSE len(@ssortingng) + 1 END - @pos - 1 INSERT @out VALUES (convert(nvarchar, subssortingng(@ssortingng, @pos + 1, @valuelen))) SELECT @pos = @nextpos END RETURN END