I have to make a Transfer MDB file form One Database system to another:
Original table column names are numbers
aprox 5000 records)
Original Table
1 2 3 ... 68 69 70
Mgw150 PrNm1 2.0000 ... 1.0000 Null Null
Mgw150 PrNm2 4.0000 ... 1.0000 Null Null
.
.
.
The final output is should be a txt file as:
Mgw150
PrNm1
2.0000
4.0000
.
.
.
1.0000
1.0000
Null
Null
Mgw150
PrNm1
2.0000
4.0000
.
.
.
1.0000
1.0000
Null
Null
In orther to make this I have done the following steps:
1.- Append first record from original table to a one record table (Datos_Externo).
2.- pivot the table using union querys:
SELECT [1].Datos_externo.[1] AS 1, [1].[1] AS 1b, [1].[1] AS Orden
FROM 1
WHERE ((([1].[1])=1));
Union
SELECT [2].[2], [2].[1],2 as orden
FROM 2
WHERE ((([2].[1])=1));
union
SELECT [3].[3], [3].[1],3 as orden
FROM 3
WHERE ((([3].[1])=1));
union
SELECT [4].[4], [4].[1],4 as orden
FROM 4
WHERE ((([4].[1])=1));
UNION
SELECT [5].[5], [5].[1],5 as orden
FROM 5
WHERE ((([5].[1])=1));
Union
SELECT [6].[6], [6].[1],6 as orden
FROM 6
WHERE ((([6].[1])=1));
UNION
...
until 70
3.- Append first column from this union Query in an exporting table.
4.- Delete and backup from original table the first row.
5.- Cicle steps 1~4 until no record is on Original Table
6.- Export exporting Table.
Now the questions:
This process works well for 10 columns will it work for 70?
Will it be to slow, if so how can it be speed it up?
Can someone help me with a code to automate the Union query in a loop. (I am starting to learn VB on access still an amprentiz on this I am))
I made up this process reading various posts on this forums, thank you all for it.
Carlos
Original table column names are numbers
Original Table
1 2 3 ... 68 69 70
Mgw150 PrNm1 2.0000 ... 1.0000 Null Null
Mgw150 PrNm2 4.0000 ... 1.0000 Null Null
.
.
.
The final output is should be a txt file as:
Mgw150
PrNm1
2.0000
4.0000
.
.
.
1.0000
1.0000
Null
Null
Mgw150
PrNm1
2.0000
4.0000
.
.
.
1.0000
1.0000
Null
Null
In orther to make this I have done the following steps:
1.- Append first record from original table to a one record table (Datos_Externo).
2.- pivot the table using union querys:
SELECT [1].Datos_externo.[1] AS 1, [1].[1] AS 1b, [1].[1] AS Orden
FROM 1
WHERE ((([1].[1])=1));
Union
SELECT [2].[2], [2].[1],2 as orden
FROM 2
WHERE ((([2].[1])=1));
union
SELECT [3].[3], [3].[1],3 as orden
FROM 3
WHERE ((([3].[1])=1));
union
SELECT [4].[4], [4].[1],4 as orden
FROM 4
WHERE ((([4].[1])=1));
UNION
SELECT [5].[5], [5].[1],5 as orden
FROM 5
WHERE ((([5].[1])=1));
Union
SELECT [6].[6], [6].[1],6 as orden
FROM 6
WHERE ((([6].[1])=1));
UNION
...
until 70
3.- Append first column from this union Query in an exporting table.
4.- Delete and backup from original table the first row.
5.- Cicle steps 1~4 until no record is on Original Table
6.- Export exporting Table.
Now the questions:
This process works well for 10 columns will it work for 70?
Will it be to slow, if so how can it be speed it up?
Can someone help me with a code to automate the Union query in a loop. (I am starting to learn VB on access still an amprentiz on this I am))
I made up this process reading various posts on this forums, thank you all for it.
Carlos