User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 397,602 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,641 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:

Get data out of excel file stored as an image

Join Date: Sep 2006
Location: San Diego, CA USA
Posts: 99
Reputation: M_K_Higa is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
M_K_Higa's Avatar
M_K_Higa M_K_Higa is offline Offline
Junior Poster in Training

Re: Get data out of excel file stored as an image

  #7  
Nov 2nd, 2007
Yes -- you can build the statement and then use the execute command to execute the statement.

I do something similar to the following in my actual code...

  1. declare @text_01 AS varchar(1000)
  2. declare @text_02 AS varchar(500)
  3. declare @spreadsheet AS varchar(250)
  4. declare @worksheet AS varchar(250)
  5. declare @sql_statement AS varchar(2000)
  6.  
  7. SET @spreadsheet = 'c:\path\test.xls'
  8. SET @worksheet = 'Sheet1'
  9.  
  10. SET @text_01 = 'INSERT INTO SpreadsheetDataDump (f1,f2,f3,f4,f5,f6) SELECT f1,f2,f3,f4,f5,f6 '
  11.  
  12. SET @text_02 = ' FROM OPENDATASOURCE(''Microsoft.Jet.OLEDB.4.0'',''Data Source="'
  13. + @spreadsheet + '";Extended Properties="Excel 8.0;IMEX=1;HDR=NO"'')...'
  14. + @worksheet + '$'
  15.  
  16.  
  17. SET @sql_statement = @text_01 + @text_02
  18.  
  19. exec (@sql_statement )

In my actual code, the @spreadsheet and @worksheet variables are passed in as parameters. I've declared them in this sample code for clarity.

Hope this helps.
-Mike
Reply With Quote  
All times are GMT -4. The time now is 7:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC