spacer
cornerspacercorner
Reply
JD
Occasional Contributor
JD
Posts: 5
Registered: 11-09-2011
0 Kudos

IMporting Data from Excel Into SQl Server

I am needing to have a form that allows the user to browse to the location of the excel spreadsheet and then upload the data from one sheet into a sqlserver table..

 

Has anyone been here before? Any advice v.helpful as at the moment all I can see is a large chunck of code to try and emulate this.

 

Thanks

Employee
Ethan Beisher
Posts: 378
Registered: 05-10-2010
0 Kudos

Re: IMporting Data from Excel Into SQl Server

I have not done this, but I would think one approach would be:

 

- Use a standard Attachment Clip in a MBPM form

- Have a Visual Script "When Action Completed" for the action that:

    - Uses the Document "Get Attachment" to save that attachment somewhere on the MBPM Server

    - Use a Commands "Code Activity" to have C# code insert that spreadsheet into the database. Here is an example.

Ethan Beisher
Solutions Engineer
Business Process Solutions
JD
Occasional Contributor
JD
Posts: 5
Registered: 11-09-2011
0 Kudos

Re: IMporting Data from Excel Into SQl Server

[ Edited ]

Thanks for the link.... I couldn't see the option to copy from excel into the Database, so I wouldn't mind some steer there.

 

Also in the examples you poimted me towards uses the using statement which I beleive cannot be used in the scripting screens.

 

 

Occasional Visitor
MonajVerma
Posts: 1
Registered: 02-11-2012
0 Kudos

Re: IMporting Data from Excel Into SQl Server

Hello Everyone,

I'm facing one problem since last night. Actually I want to import data in SQL Server from different file format such as csv, txt, sql etc. So I want to know whether any option in SQL Server to perform such kind of actions or I have to use any third party tool to resolve this problem. Please give me your valuable suggestion.

Thanks in advance!

Employee
Tony Wheeler
Posts: 67
Registered: 05-02-2011
0 Kudos

Re: IMporting Data from Excel Into SQl Server

Hi JD, If you chose to go this route,  there wouldn't really be an option to just copy to the database. You'd be treating your user's newly uploaded xlsx file as a data source, selecting all the rows from it, then mass inserting the rows into your SQL database. This will require some code in a server side script. You would have to first write the file to a temp location from the database (after the upload) using GetAttachment.  Also, "using" statements are absolutely supported in server side scripts. Anything in the .Net 3.5 framework can be used as long as the supporting DLLs are in the proper folders. See "Custom DLLs" in the Designer User Guide.
Employee
Tony Wheeler
Posts: 67
Registered: 05-02-2011
0 Kudos

Re: IMporting Data from Excel Into SQl Server

Hi MonajVerma, In your case, I would recommend looking into SSIS... some people still refer to it as DTS.  This comes with SQL Server and allows for a semi- visual way to import data from many different sources and formats... Although, for one-off jobs with hairy insert/update logic, the path of least resistance is often to just write a quick little console app that selects your data table from one source and inserts the rows into another. I would check with your DBA as they may already have utilities/methods in place because pushing data around is a fairly common task.
Employee
Ethan Beisher
Posts: 378
Registered: 05-10-2010
0 Kudos

Re: IMporting Data from Excel Into SQl Server

You can use the using statement. It may be easier to create a separate Server Script to do your coding in.

Ethan Beisher
Solutions Engineer
Business Process Solutions
line spacer line
spacerFollow Metastorm on:
spacer Twitter YouTube Blog iTunes LinkedIn Metastorm Community Central, MC2
spacer Copyright © 2011 OpenText Corporation. All Rights Reserved.spacer About Metastormspacer Privacyspacer Legalspacer Site Mapspacer RSSspacer Contact Us
Microsoft Gold Certified Partner
Powered by Windows Azure
line spacer line