uerobertson
Programmer
Hi,
I am writing a stored procedure to convert our client's data and move it into our database. I am using SQLSvr 2000 and Win2000.
I have a table containing 3 fields:
Table1
ID | Date | Code
-----------------
1 | Jan 1 | OD1
-----------------
1 | Feb 1 | SD1
-----------------
1 | Mar 1 | OD2
-----------------
1 | Apr 1 | SD2
-----------------
1 | May 1 | OD3
-----------------
1 | Jun 1 | SD3
-----------------
2 | Jul 1 | OD1
-----------------
2 | Aug 1 | SD1
-----------------
2 | Sep 1 | OD2
-----------------
2 | Oct 1 | SD2
-----------------
2 | Nov 1 | OD3
-----------------
2 | Dec 1 | SD3
-----------------
. . .
. . .
. . .
I would like to directly insert this data into another table and end up with this:
Table2
ID | oDate1 | sDate1 | oDate2 | sDate2 | oDate3 | sDate3
---------------------------------------------------------
1 | Jan 1 | Feb 1 | Mar 1 | Apr 1 | May 1 | Jun 1
---------------------------------------------------------
2 | Jul 1 | Aug 1 | Sep 1 | Oct 1 | Nov 1 | Dec 1
---------------------------------------------------------
etc.
(Please excuse the rather inane sample data)
What is the best way of doing this in an insert statement? I have been working on this for some time and so far have only disconnected scribbling.
Thanks for your help.
U.
I am writing a stored procedure to convert our client's data and move it into our database. I am using SQLSvr 2000 and Win2000.
I have a table containing 3 fields:
Table1
ID | Date | Code
-----------------
1 | Jan 1 | OD1
-----------------
1 | Feb 1 | SD1
-----------------
1 | Mar 1 | OD2
-----------------
1 | Apr 1 | SD2
-----------------
1 | May 1 | OD3
-----------------
1 | Jun 1 | SD3
-----------------
2 | Jul 1 | OD1
-----------------
2 | Aug 1 | SD1
-----------------
2 | Sep 1 | OD2
-----------------
2 | Oct 1 | SD2
-----------------
2 | Nov 1 | OD3
-----------------
2 | Dec 1 | SD3
-----------------
. . .
. . .
. . .
I would like to directly insert this data into another table and end up with this:
Table2
ID | oDate1 | sDate1 | oDate2 | sDate2 | oDate3 | sDate3
---------------------------------------------------------
1 | Jan 1 | Feb 1 | Mar 1 | Apr 1 | May 1 | Jun 1
---------------------------------------------------------
2 | Jul 1 | Aug 1 | Sep 1 | Oct 1 | Nov 1 | Dec 1
---------------------------------------------------------
etc.
(Please excuse the rather inane sample data)
What is the best way of doing this in an insert statement? I have been working on this for some time and so far have only disconnected scribbling.
Thanks for your help.
U.