On Thu, Oct 21, 2010 at 1:03 PM, Ketan Jetty <[email protected]> wrote:
>
> Another way to do this is read the file, loop thru the lines and massage
> the data as wanted when inserting into the database. This way you can have
> better control on the data manipulation.
>
> <cfloop file="#expandPath('.')#\sampledata.csv" from="1" index="line">
> <cfquery name="qi" datasource="#mydsn#">
> INSERT INTO tableONE
> (
> col1
> ,col2
> ,col3
> ,col4
> )
> VALUES
> (
> '#ListGetAt(line,1)#'
> ,'#ListGetAt(line,2)#'
> ,'#ListGetAt(line,3)#'
> ,'#ListGetAt(line,4)#'
> )
> </cfquery>
> </cfloop>
>
> Thanks,
>
> Ketan Jetty
> http://KetanJetty.com
>
>
If this is MS SQL you can do this as well.
Right click the Database, select tasks, import data, select Excel as source
of data, then the DB and table you are inserting it to, there is options to
align the colums with the column names in the table, then run.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338449
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm