|
 |
access thread: Import selected Excel columns into SQL
Message #1 by "Tim Shirey" <Tim.Shirey@a...> on Mon, 28 Oct 2002 20:02:06
|
|
I have tried using the DTS Wizard, but it only selects the Excel columns
and stops there. How do I finish the SQL statements to import the
selected columns into the database?
The current statement reads:
select `Sheet1$`.`Birth_Date`, `Sheet1$`.`CPU_Speed`, `Sheet1
$`.`No_of_CPU`, `Sheet1$`.`OS_Type`, `Sheet1$`.`OS_Ver`, `Sheet1
$`.`Primary_IP`, `Sheet1$`.`Serv_Domain`, `Sheet1$`.`SP_Level`
from `Sheet1$`
My database is app_systems and the table is ServerList. The columns names
for the data to go into are the same as the columns names above.
Thanks,
Tim
Message #2 by "Bob Bedell" <bobbedell15@m...> on Mon, 28 Oct 2002 21:44:04 +0000
|
|
Hi Tim,
You're OK so far. With your current Query Statement displayed in the
Type SQL Statement dialog, click Next. In the Select Source Tables and
Views dialog you'll see a Table(s)/Worksheets(s)/Excel Named Range(s)
grid.
1. Click the arrow next to the Destination column
2. Select [app_systems].[dbo].[ServerList] as your destination table
3. Click the button in the Transform cloumn
4. With the Append Rows to Destination Table option selected on the
the Column Mapping tab, map your Excel columns to your table
columns. SQL Server may already have done that for you. Just click
in a field of the Source column and you get a drop down list of your
Excel column names.
5. Click the Transformations tab and you can view the transformation
script SQL Server Creates:
'**********************************************************************
' Visual Basic Transformation Script
' Copy each source column to the
' destination column
'************************************************************************
Function Main()
DTSDestination("Birth_Date") = DTSSource("Birth_Date")
DTSDestination("CPU_Speed") = DTSSource("CPU_Speed")
DTSDestination("No_ofCPU") = DTSSource("No_ofCPU")
DTSDestination("OS_Type") = DTSSource("OS_Type")
DTSDestination("OS_Ver") = DTSSource("OS_Ver")
DTSDestination("Primary_IP") = DTSSource("Primary_IP")
DTSDestination("Serv_Domain") = DTSSource("Serv_Domain")
DTSDestination("SP_Level") = DTSSource("SP_Level")
Main = DTSTransformStat_OK
End Function
6. Click OK, a few Nexts (Be sure the Run Immediately check box is
checked when you get to it) and Finish.
Your Excel data should now be appended to your SQL Server table. Hope
it works OK.
Best,
Bob
>From: "Tim Shirey" <Tim.Shirey@a...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] Import selected Excel columns into SQL
>Date: Mon, 28 Oct 2002 20:02:06
>
>I have tried using the DTS Wizard, but it only selects the Excel columns
>and stops there. How do I finish the SQL statements to import the
>selected columns into the database?
>
>The current statement reads:
>select `Sheet1$`.`Birth_Date`, `Sheet1$`.`CPU_Speed`, `Sheet1
>$`.`No_of_CPU`, `Sheet1$`.`OS_Type`, `Sheet1$`.`OS_Ver`, `Sheet1
>$`.`Primary_IP`, `Sheet1$`.`Serv_Domain`, `Sheet1$`.`SP_Level`
>from `Sheet1$`
>
>
>My database is app_systems and the table is ServerList. The columns names
>for the data to go into are the same as the columns names above.
>
>Thanks,
>
>Tim
_________________________________________________________________
Unlimited Internet access -- and 2 months free! Try MSN.
http://resourcecenter.msn.com/access/plans/2monthsfree.asp
|
|
 |