Thursday, 18 June 2015

Import Data from EXcel to Sql Table using Import in SQL Management studio.


Before we start importing data into SQL Server, let’s create a database first.  We are going to name itDemo.
  • Start SQL Server Management Studio under Microsoft SQL Server 2008 R2.
image
  • Enter .\SqlExpress in Server name: and click Connect button.
image
  • Microsoft SQL Server Management Studio is now launched
image
  • Right Click on Databases and Select New Database…
image
  • New Database dialogue is displayed.
  • Enter Demo in Database name:
  • Change the Initial Size (MB) to 50 and 5 for Demo and Demo_log respectively.
  • Click OK button.
image
  • Demo database is ready to use.
image

Import Excel Into SQL Server

We are going to use the Import and Export Wizard from SQL Server; it is a very powerful tool that we can use it to import and export a wide range of data files.  We are going to use it to import Excel.
  • Start Import and Export Data (32-bit) under Microsoft SQL Server 2008 R2
image
  • SQL Server Import and Export Wizard is launched, click Next button
image
  • Select Microsoft Excel as Data source
  • Enter the location of Excel file in Excel file path:
  • Click Next button.
image
  • Choose SQL Server Native Client 10.0 as Destination
  • Enter M1330\SQLExpress in Server name.
  • Select Demo as Database
  • Click Next button.
image
  • Select Copy data from one or more tables or views
  • Click Next button.
image
  • Select ‘Sheet 1$’
  • Click Edit Mappings…
image
  • Import and Export Wizard would automatically create the table structure for us but we can modify it.
  • Click OK button to return to Wizard.
  • Click Next button.
image
  • Import and Export Wizard now created a package for us, and we can run it immediately.
  • Click Next button.
image
  • Click Finish button.
image
  • Click Close button to close the status dialogue.
image
  • Let’s go back to Microsoft SQL Server Management Studio
  • We noticed that there was a new table “dbo.Sheet1$.
image
  • Let’s rename it to ContosoStore
image
  • Table name is changed to ContosoStore.
image
  • Let’s look at the content of the table.
image
  • A SQL statement is generated for us and we can see the result dataset.
image

No comments:

Post a Comment