SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 OpenRowSet help..
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Vishal_sql
Posting Yak Master

101 Posts

Posted - 12/24/2012 :  01:35:49  Show Profile  Reply with Quote
Hi All,

I am uploading the Excel file from Excel 2007 to SQL Server 2005 using OPENROWSET.
First "row" of Excel file has 38 columns of which 9 clomuns have Projectdetails and remaning as Date in incremental of 7 days.
eg:-
1st row (which would be columns after importing) is like
client | projectcode |.. 12/01/2012 | 12/08/2012 | 12/15/2012 |... 16/15/2013

The dates in excel are incremented like cell1+7,cell2+7..

So after importing i am getting 9 columns are tablename properly but the dates are imported as F1 | F2 | F3 ....F38 instead of actual dates in SQL Server table.

How can I get the dates in table after importing
Any suggestion would be helpful.

Vishal_sql
Posting Yak Master

101 Posts

Posted - 12/24/2012 :  08:45:14  Show Profile  Reply with Quote
I did it by saving the excel to CSV first ,
so now the formulaes in excel are actual dates used in CSV.
it worked :)

and then used following for importing the CSV.

select * into Tablename
from openrowset ('Microsoft.JET.OLEDB.4.0','Text;Database=H:\;','select * from [csvfilename.csv]')



Go to Top of Page

Vishal_sql
Posting Yak Master

101 Posts

Posted - 12/28/2012 :  00:59:33  Show Profile  Reply with Quote
quote:
I am uploading the Excel file from Excel 2007 to SQL Server 2005 using OPENROWSET.
First "row" of Excel file has 38 columns of which 9 clomuns have Projectdetails and remaning as Date in incremental of 7 days.
eg:-
1st row (which would be columns after importing) is like
client | projectcode |.. 12/01/2012 | 12/08/2012 | 12/15/2012 |... 16/15/2013

The dates in excel are incremented like cell1+7,cell2+7..

So after importing i am getting 9 columns are tablename properly but the dates are imported as F1 | F2 | F3 ....F38 instead of actual dates in SQL Server table.

How can I get the dates in table after importing
Any suggestion would be helpful.


Can any one having other approach
As my Excel is having formulaes i cant read it using openrowset,so i converted it in CSV manually first and read the CSV.
Can I do it instead of converting it in CSV ?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000