.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Inserting and updating 2 tables in sql server 2008 from 2 worksheets in Excel

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net

hi all,

        I have an excel sheet with 2 tabs and has data in those 2 sheets(sheet1, sheet2) which correspond to different tables in the same database. This excel sheet gets updated daily, I am wiriting a console app( which will later be a batch build). I have to  insert the data from the excel sheet to corresponding tables (table1, table2,table3) in database when i run it and and also if the table has the same data already present it should ignore and if there are any modifications done the data it should update the table. I know we can do this using ado.net or LINQ, I am a little new to database based programming ..so any help is more appreciated. I have already tried googling but colud not find the perfect solution.

View Complete Post

More Related Resource Links

Importing Access 2010 tables to SQL Server 2008 R2

I'm trying to import a series of Access 2010 tables to Sql Server 2008 R2.  The Access import drivers are for *.mdb (which if I recall was the file extension for Access when I was a kid, and don't recognize the .accdb file extention).  Similarly, the Excel driver is for Excel 2003.  Isn't there a driver and method to import directly to SQL 2008 from Access 2010? SQL is installed on my server, but Access is not installed on the server.  When I copy the file onto the server and try and open it directly into SQL, I get a 'no editor installed' error. I can't get the 'upsize' wizard to work becuase it won't open the connection to SQL, even though I enter the userid and password of the SQL DB owner.  I get the following error: ===================================================== Connection failed: ============================================================= I have to say I'm stumped.  The rest of the Office 2010 suite works really well together - perhaps I'm missing something very simple? Thanks!     I guess I could export my tables as Excel 2003 and then import them using Integration Services, or install SQL Express on my laptop and 'upsize' to that instance, but SQL State: ‘0100’ SQL Server Error: 11004 [Microsoft][ODBC SQL Server Dirver][TCP/IP Sockets]ConnectionOpen (Connect()). Connection failed: SQL

Import Excel data into SQL Server express 2008

I have recently installed SQL express 08 and created a table to import excel data into.  Im running on a windows 7 64 bit OS i5 processor.  I've disabled the firewall (temporarily) and will set the necessary ports once this is working. I run the following query:  (which i found from multiple sources on the net) Select   * From OPENROWSET ( 'Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\Users\Public\lenovoBkup\contacts\outlookFiles\noib2a.xls', 'Select * From [sheet1$]' )  and receive the following message: Msg 7308, Level 16, State 1, Line 1                                                                                  OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.  (how did they know i was single and living in an apartment? lol) so after research of the following message i restarted the system and relaunched man

How to create a SSIS package to import records form SQl Server 2008 tables to text files

I am a newbie to SSIS and would like to create a package to accomplish the task referenced in the above title. Will appreciate any links and pointers in the right direction.   Thanksakoranteng

SQL Server 2005 Analysis Services - Performance of Excel Pivot Tables

Hi, I've several cubes available for several users within my organization. I've the SQL Server 2005 and the Analysis Services running on the same machine but it has 30Gb of RAM, 8 processors and a quick enouth disk. The problems is that i've some automatic processes that "build" some excel reports and the users use pivot tables with olap connections to the cubes regularly. I've noticed that the excel "locks" when the user is drilling down the data and the server has only one processor (there are 8...) at 100%... Is there a way to make the analysis services use the maximum processing capacity that is available? The users are complaining about the slowness of the cubes... Thanks in advance Hugo

Microsoft SQL Server Management Studio 2008 does not list all tables in database

When logging into SSMS 2008 to a SQL2008 database when I expand the tables in a database I only see a few tables listed.  I can login to the same instance with SSMS 2005 and all of the tables are there.  Is there a reason why this is this way?

I can do a select * from in a query window for any of the tables in the database via SSMS 2008 as well and it work fine.  It just does not display the tables.

"PivotTable.DisplayEmptyRows = false " in Excel pulling from Analysis Server 2008, doesn't work.


We display financial information, using Excel pulling from Analysis Server 2008.


In vba,  "ptTemp.DisplayEmptyRow = false" works fine for hiding empty rows of data on most pivot tables, but if the "account numbers" parent/child dimension is in the row fields, it doesn't.


The row Dimension look like this:


Balance Sheet


Current Assets


Total Balance Sheet


Income Statement

Gross Profit


Item A


Total Income Statement

Unable to connect Excel 2003 from linked server in sql 2008 64 bit


I was unable to connect to excel 2003 with linked server created in sql server 2008 64 bit. This was working fine with sql server 2005 32 bit.

I know that there no 64 bit drivers for JET drivers, but i am looking for some alternative ways to do the same job.

I dont want to migrate to Excel 2007.

Thanks in advance for all your help.


Inserting XML into SQL Server 2008 table



I'm generating an XML file from front end, I'm using 4 Data Transfer Object classes comprising of full details of a Customer like CustomerPersonalInfoDTO.cs, CustomerLoginInfoDTO.cs, CustomerPreviousAddressDTO.cs, CustomerAddressInfoDTO.cs.

Everything is fine and XML is also generated, But the problem is with SQL Server Stored Procedure. I've created a table Customer with 20 columns.

CustomerPersonalInfoDTO.cs holds 10 customer fields and CustomerLoginInfoDTO.cs holds another 10 customer fields (total =20)..

I now need to insert at a time these 20 FIELDS into SQL server Customer Table. My XML Data will look like the below:

<?xml version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ?> 
- <CustomerDTO>

- <CustomerPersonalInfo>

Microsoft Excel Application in DCOMCNFG in Windows Server 2008

Microsoft Excel Application in DCOMCNFG in Windows Server 2008 is not found. This is presnt in windows server 2003. But how to configure this in Windows Server 2008.

Kindly help me as soon as possible.

Inserting/updating DB looping Excel data of huge number of records




    I have requirement to read the excel data and based on some conditions ih ave either insert/ update the data in to Oracle tables. to check the condition I have to loop through the 4 columns for 4 conditions which may consist of huge number of records, where performance issue arise here. please put me in the right way or suggest me a best approach to break through the performance issue as well.

ofcourse i am writing in a service.

temporary tables in SQL Server 2008


Are there any changes in the rules for creating temporary tables in SQL Server 2008 comparing to 2005? 2008 example in 'SELECT INTO' explicitly uses 'tempdb' while in 2005 any database was OK. Is this just an illustration or change in the features?



Exporting SQL Server Tables to Excel Programmatically from .NET


Honestly I am a bit confuse where to post this question, whether Excel Forum, SQL Server forum, or .NET forum.

I need to export certain table from SQL Server DB to an excel file, programmatically trigger from .NET. It means, at my application, I can select a few tables (let say 3 tables: customer, product, category) and when I click "Export to Excel" button, it exports to an excel file with 3 different sheet according to the table I selected.

I know there are many way to achieve that as I find:

While those solution provids customizable solution from code, it also require quite lots of effort. Whereby, in my case, I don't need any customization, so

How to Import Excel Data into SQL Server 2008(64 bit) Using SQL Query (in Windows Server 2008 64bit

I am developing VB .Net application in Visual Studio 2008(64bit), SQL Server 2008(64bit) and Windows Server 2008(64bit) environment.

I need to import an Excel and Flat files data into SQL Server database using SQL Query. I tried a lot with the following SQL Queries directly with SQL Server Management Studio,

1. SELECT * INTO  dbo.ExcelImportTest FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\PTPLDCT\DCT Test Datasource\DCT_Excel_Test_Sample_1.xls',
'select * from [Sheet1$]')

While executing i got an error as below,

Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

2. I have also tried with MSDASQL provider,

Select * from openrowset('MSDASQL','Driver={Microsoft Excel Driver (*.xls)};
Dbq=DCT_Excel_Test_Sample_1.xls;DefaultDir=D:\PTPLDCT\DCT Test Datasource\', 'Select * from [Sheet1$]')

Then i encountered the following error,

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

3. Finally i have tried the Query with Linked Server,

EXEC sp_addlinkedserver @server = '

sql server 2008 not showing and inserting unicode characters!



i am inserting unicode data into sql server 2008 , but my script file is showing a box instead of the actual unicode character.i.e if i have a text file (a notepad file saved with unicode encoding) and i copy paste any unicode character from there to my sql server script file , it shows a box instead of the unicode character.

and when i insert the data like this , the ? character is inserted instead of the box.

what to do now ?

Accessing Excel\Access files through Sql Server 2008 R2 Stand 64 BIT



This has been just such a pain with 64 bit! Data Access!!  I have been unable to use linked servers from SQL server to access files because there is no Jet 64 bit. Now, I have been using bulk insert statements.  These are working ok, but for some uknown reason, for a certain .csv file I am getting unexpected end of line errors.  I have tried many things to no resolution..

How can I get linked servers to work with SQL Server 64 bit for excel and access?  Why would microsoft leave this out??



Export to Excel 2007 Problem - SQL Server 2008



Hi! I did a quick test to dump data into an Excel spreadsheet. Everything worked fine, but when I created a job to do this for me and then run it, I get this error:


Date  10/8/2008 4:24:25 PM
Log  Job History (ExportClientInfoToSpreadsheet)

Step ID  1
Server  OHI0056
Job Name  ExportClientInfoToSpreadsheet
Step Name  CreateExcelClientExport
Duration  00:00:00
Sql Severity  0
Sql Message ID  0
Operator Emailed  
Operator Net sent  
Operator Paged  
Retries Attempted  0

Executed as user: OHI0056\SYSTEM. Microsoft (R) SQL Server Execute Package Utility  Version 10.0.1600.22 for 64-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Option "12.0;HDR=YES;" is not valid.  The command line parameters are invalid.  The step failed.


Here is the script of the job. Any ideas what is going on?





USE [msdb]


/****** Object: Job [ExportClientInfoT

Updating SQL Server 2008 R2



I have a SQL Server 2008 R2 installation. Does it exists any CUs or SPs about it?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend