dbTalk Databases Forums  

import excel spreadsheet to sql via vb or java script

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


Discuss import excel spreadsheet to sql via vb or java script in the microsoft.public.sqlserver.dts forum.



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

Default import excel spreadsheet to sql via vb or java script - 04-24-2004 , 10:45 PM







All,

I am looking for a vb or java script that will delete an sql table named
Daily_List, then import an excel spreadsheet from a network share (in a
public folder) into sql server 2000 and name it Daily_List.

a few things to note, the excel spreadsheet name changes daily based on
the date, for instance todays filename is "filename 04242004.xls",
tomorrows will be "filename 04252004.xls" and so on.


Any and all help is greatly apprecitated,

Thanks,

Fred

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: import excel spreadsheet to sql via vb or java script - 04-25-2004 , 12:12 AM






One way to do this would be to

DROP TABLE Daily_List

You can easily predict the name of the Excel File and you can build it up so
something like this

Declare @xlfilename varchar(120)
Declare @statement varchar(255)
set @xlfilename = CONVERT(char(8),getdate(),112)
SET @statement = 'SELECT * INTO Daily_list FROM OpenDataSource(
''Microsoft.Jet.OLEDB.4.0'',''Data Source="c:\' + @xlfilename + '.xls";User
ID=Admin;Password=;Extended properties=Excel 5.0'')...Sheet1'
print @statement
exec(@statement)





--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Fred" <Fred (AT) home (DOT) com> wrote

Quote:
All,

I am looking for a vb or java script that will delete an sql table named
Daily_List, then import an excel spreadsheet from a network share (in a
public folder) into sql server 2000 and name it Daily_List.

a few things to note, the excel spreadsheet name changes daily based on
the date, for instance todays filename is "filename 04242004.xls",
tomorrows will be "filename 04252004.xls" and so on.


Any and all help is greatly apprecitated,

Thanks,

Fred

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply With Quote
  #3  
Old   
Fred
 
Posts: n/a

Default Re: import excel spreadsheet to sql via vb or java script - 04-26-2004 , 09:11 PM





This work very well with one execption.....My file names date format is
mmddyyyy, and sql either puts dashes between dates or uses the format
yyyyddmm. is there a way to make sql flip flop the date?

as posted before, my filename is "filename date.xls" (filename
04262004.xls) and the date changes daily. sql does not like that.

can anyone help me with a script that can do this?


thanks

Fred

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: import excel spreadsheet to sql via vb or java script - 04-27-2004 , 12:09 AM



Then you build the statement yourself. You can easily grab the date and
turn it into that format. You then append after casting to a string the new
dateformat to the filename.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Fred" <Fred (AT) home (DOT) com> wrote

Quote:

This work very well with one execption.....My file names date format is
mmddyyyy, and sql either puts dashes between dates or uses the format
yyyyddmm. is there a way to make sql flip flop the date?

as posted before, my filename is "filename date.xls" (filename
04262004.xls) and the date changes daily. sql does not like that.

can anyone help me with a script that can do this?


thanks

Fred

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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.