dbTalk Databases Forums  

Import from Excel with variables

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Import from Excel with variables in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ashton
 
Posts: n/a

Default Import from Excel with variables - 10-27-2005 , 04:04 PM






I'm assuming this is a simple question, I can't find a solution though.
Hopefully this makes sense

1) I have an excel file with the following columns:
First Name
Last Name
Email

2) I have a table with the following columns:
ID (primary key)
ExcelID (int not null)
FirstName varchar
LastName varchar
Email varchar

ExcelID is a number that is used to determine what file the user information
came from... it isn't a part of the excel file. Basically I want to run a DTS
that inserts the excel file columns AND sets ExcelID to a value that I'll be
entering.

I can import the data from excel just fine. How do I add an option to set a
column (in the database) just to a VALUE not a reference to a column in the
spreadsheet?


Reply With Quote
  #2  
Old   
Panch
 
Posts: n/a

Default Re: Import from Excel with variables - 10-27-2005 , 06:53 PM






Ashton

You need to create a ActiceX Script in the Transformation tab.

A Panchanathan

ashton wrote:
Quote:
I'm assuming this is a simple question, I can't find a solution though.
Hopefully this makes sense

1) I have an excel file with the following columns:
First Name
Last Name
Email

2) I have a table with the following columns:
ID (primary key)
ExcelID (int not null)
FirstName varchar
LastName varchar
Email varchar

ExcelID is a number that is used to determine what file the user information
came from... it isn't a part of the excel file. Basically I want to run a DTS
that inserts the excel file columns AND sets ExcelID to a value that I'll be
entering.

I can import the data from excel just fine. How do I add an option to set a
column (in the database) just to a VALUE not a reference to a column in the
spreadsheet?


Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Import from Excel with variables - 10-29-2005 , 04:51 AM



Hello ashton,

You need to assign the value of the Excel connection's DataSource property
to a global variable.

Now you have that, in your transformations section of the Data Pump task
you highlight the destination column and add an Active X transform. Check
there are no source columns.

In the script you do this

DTSDestination("MyColumn") = DTSGlobalVariables("My Varaible").Value


When you look at this transform in the designer you will see it originate
from thin air above the Source Columns box and end at your destination column.


Allan


Quote:
I'm assuming this is a simple question, I can't find a solution
though. Hopefully this makes sense

1) I have an excel file with the following columns:
First Name
Last Name
Email
2) I have a table with the following columns:
ID (primary key)
ExcelID (int not null)
FirstName varchar
LastName varchar
Email varchar
ExcelID is a number that is used to determine what file the user
information came from... it isn't a part of the excel file. Basically
I want to run a DTS that inserts the excel file columns AND sets
ExcelID to a value that I'll be entering.

I can import the data from excel just fine. How do I add an option to
set a column (in the database) just to a VALUE not a reference to a
column in the spreadsheet?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.