If I were you, I would create a simple function that separates the values โโseparated by the ';' eg:
IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'fn_Split_List') AND xtype IN (N'FN', N'IF', N'TF')) BEGIN DROP FUNCTION [dbo].[fn_Split_List] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[fn_Split_List](@List NVARCHAR(512)) RETURNS @ResultRowset TABLE ( [Value] NVARCHAR(128) PRIMARY KEY) AS BEGIN DECLARE @XML xml = N'<r><![CDATA[' + REPLACE(@List, ';', ']]></r><r><![CDATA[') + ']]></r>' INSERT INTO @ResultRowset ([Value]) SELECT DISTINCT RTRIM(LTRIM(Tbl.Col.value('.', 'NVARCHAR(128)'))) FROM @xml.nodes('//r') Tbl(Col) RETURN END GO
What is simply called like this:
SET NOCOUNT ON GO DECLARE @RawData TABLE( [Value] NVARCHAR(256)) INSERT INTO @RawData ([Value] ) VALUES ('1111111;22222222') ,('3333333;113113131') ,('776767676') ,('89332131;313131312;54545353') SELECT SL.[Value] FROM @RawData AS RD CROSS APPLY [fn_Split_List] ([Value]) as SL SET NOCOUNT OFF GO
The result is as follows:
Value 1111111 22222222 113113131 3333333 776767676 313131312 54545353 89332131
In any case, the logic in the function is not complicated, so you can easily place it anywhere.
Note. There is no limit on how many values โโyou would share with ;; but the function that you can install on NVARCHAR (MAX) has a length limit.
EDIT:
As I can see, in your example there are several lines that make the function return empty lines. For instance:
number;number;
will return:
number number '' (empty string)
To clear them, simply add the following where expression to the above expression:
SELECT SL.[Value] FROM @RawData AS RD CROSS APPLY [fn_Split_List] ([Value]) as SL WHERE LEN(SL.[Value]) > 0