HELP.
I have in the link below the CSV file with 4,782,969 records.
https://azhivw.dm.files.1drv.com/y4mkm8-0scnW2IvW98j-RDc1vXpYg2k6YkQdVlQD2URN6dbB18LZLXtqNDrkVH9Ns55RQFz3A7dXBm4TV8qZMd0eS1-8d30nQnSt7nnp1zi1gqgznwK-yGl_sqmXbuBMmpNoIPja0zbUoS30ieoTMVWTh-iM4a7UxdQUqjhHhMzpZXpnC9KmTH1n1sfQND5dD09/14sNumeros.csv.zip?download&psid=1
Id, COLL1, COLL2, COLL3, COLL4, COLL5, COLL6, COLL7, COLL8, COLL9, COLL10, COLL11, COLL12, COLL13, COLL14
For each of the lines would need to compare with the 4782969 and find the 28 lines where there are 13 of the 14 equal columns and generate a new CSV with ID, ID2,
Since the ID is the ID and the ID2, the 28 ID's that contain 13 columns are the same.
With help, make a query but is very slow.
Import CSV to Table [Tbl14ids]
And
<style type="text/css">p.p1 {margin: 0.0px 0.0px 13.0px 0.0px; font: 13.0px Helvetica} </style>CREATE TABLE [dbo].[Famaly13](
[MAIN] [int] NULL,
[CHILD] [int] NULL
) ON [PRIMARY]
GO
Declare
@id Int ,
@COL1 nvarchar(1) ,
@COL2 nvarchar(1) ,
@COL3 nvarchar(1) ,
@COL4 nvarchar(1) ,
@COL5 nvarchar(1) ,
@COL6 nvarchar(1) ,
@COL7 nvarchar(1) ,
@COL8 nvarchar(1) ,
@COL9 nvarchar(1) ,
@COL10 nvarchar(1) ,
@COL11 nvarchar(1) ,
@COL12 nvarchar(1) ,
@COL13 nvarchar(1) ,
@COL14 nvarchar(1)
DECLARE cursor1 CURSOR FOR
select [Id],[COLL1],[COLL2],[COLL3],[COLL4],[COLL5],[COLL6],[COLL7],[COLL8] ,[COLL9],[COLL10],[COLL11],[COLL12],[COLL13],[COLL14]
from [dbo].[Tbl14ids] ORDER BY ID
OPEN cursor1
FETCH NEXT FROM cursor1 INTO @ID , @COL1, @COL2, @COL3, @COL4, @COL5, @COL6, @COL7, @COL8, @COL9, @COL10, @COL11, @COL12, @COL13, @COL14
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT Famaly13
SELECT @ID, ID FROM [dbo].[Tbl14ids]
where
(Case when Coll1= @Col1 then 1 else 0 end ) +
(Case when Coll2= @Col2 then 1 else 0 end ) +
(Case when Coll3= @Col3 then 1 else 0 end ) +
(Case when Coll4= @Col4 then 1 else 0 end ) +
(Case when Coll5= @Col5 then 1 else 0 end ) +
(Case when Coll6= @Col6 then 1 else 0 end ) +
(Case when Coll7= @Col7 then 1 else 0 end ) +
(Case when Coll8= @Col8 then 1 else 0 end ) +
(Case when Coll9= @Col9 then 1 else 0 end ) +
(Case when Coll10= @Col10 then 1 else 0 end ) +
(Case when Coll11= @Col11 then 1 else 0 end ) +
(Case when Coll12= @Col12 then 1 else 0 end ) +
(Case when Coll13= @Col13 then 1 else 0 end ) +
(Case when Coll14= @Col14 then 1 else 0 end ) = 13
FETCH NEXT FROM cursor1 INTO @ID , @COL1, @COL2, @COL3, @COL4, @COL5, @COL6, @COL7, @COL8, @COL9, @COL10, @COL11, @COL12, @COL13, @COL14
END
CLOSE cursor1
DEALLOCATE cursor1