Excel database values to SQL Server and different tables - sql

I got an Excel file with data which I want to import into a database in Microsoft SQL Server 2008 Express edition.
I do this with right click on a database -> task -> import data.
After this, my data from Excel is loaded in the database in one table.
But I want to seperate the columns from the Excel file into different tables.
So instead of loading all Excel data into one database and table, I want to load the Excel data into one database, but in different tables.
For example: Save column 1,2,3 from Excel in table A, and save column 4,5,6 from Excel in table B.
Anyone that knows how to do this?

I followed the suggestion of #bendataclear:
"Personally I would just import into a temporary table then write INSERT INTO X SELECT queries to move in the correct columns."

Related

Joining SQL Database Table with Excel Sheet Data Using Power Query

I'm accessing a table in a SQL database through Excel Power Query and I want to do a join with some data that I have in a excel sheet. I don't have write access to the database so I'm not able to just create a table with the Excel data there.
Is there a good workaround that would allow me to join the database table with the data in the Excel sheet?
If you load the data from the SQL database in a query you can merge it with another query in the power query editor. You just have to navigate to the power query editor and find the merge button.
The editor will ask which are the two queries you want to merge and to indicate which columns contain the matching data.
Several types of join are supported.

Can you use excel lookup table in SQL database pull?

Is there a way to import a lookup table of account numbers from excel and only pull results from the database that match the account numbers listed in the excel lookup table? My lookup table contains thousands of account numbers so I can't manually type in the results that I want to filter for. I am using Microsoft SQL server studio to pull data from a SQL server database.
Yes, from SSMS in the object explorer you can right click on the database Tasks-->Import Data. From there you can use the UI to import the spreadsheet as a table in your database.

Insert data from excel to sql table

I have an SQL database that contains a table with 5 rows (and 4 columns). I need to import a very long table (100+ rows, same number of columns) that I have created in Excel. Is there an easy, quick way to do this 'paste'-like operation?
In SQL Server Managment
Right Click on the DB Name in the solution explorer
Select Tasks-> Import Data
In the opened wizard choose 'Microsoft Excel' as data source
Select the excel file path and the excel version
Clisk next and choose the destination table details
Finish

How can I join Excel column and SQL View?

I have an Excel spreadsheet, with one worksheet, with one column, containing key values I want to use to lookup data in a SQL Server view.
I can import the view data just fine using ADO or ODBC, but cannot figure out how to have the "Microsoft Query" tool add both the Excel Worksheet and the SQL View in a single query, so that I can join the data. I had also hoped VLOOKUP might lookup external data, but did not find anything,
I have looked for hours and am stumped. Certainly this can be done somehow where I can use a key in an Excel file to fetch a single related SQL table row back into Excel? I'm a hard core C# developer but seem to regularly struggle with Excel...
I would import the excel data into a staging table in your SQL Server database.
Of course you can use ADO to get the excel data into SQL Server.
Then you can join the view with your staging table.
hope this helps.

How to populate look up tables in sql?

Hi i am working on look up tables first time and we have some distinct values in look up tables which are coming from excel sheets. So i have two databases say A and B. there are around 22 look up tables and 5 certified tables in database A. and one import table and few work table in database B. i am just wondering how i am going to load Look up tables. do i have to write stored procs for each look up table and use in SSIS package. i just have to get distinct values from the Excel sheet for respective look up tables. i am using SQL Server 2005. Thanks for reading this.
1) Save the excel sheet as csv (use "Save As" from file menu)
2) Set "IGNORE_DUP_KEY" option on the destination table, this will skip duplicate values in CSV files(excel sheet)
3) construct a BULK INSERT command and provide the csv file and the destination table.
Alternative to 2) You may also set MAXERRORS in the BULK INSERT command to a value higher than the number of lines in csv file, this options just ignores any errors(there fore all the duplicate key errors will not cause the INSERT to fail)