I am trying to copy and paste from SQL Server 2012 to Excel 2010.
My query has the 13th column that is delimiting that is ruining the results.
It has a long description field that gets cut off after a space or a certain amount of characters.
It doesn't matter how big or small my order might be or how dumb my questions are, I get great service quickly. My account manager constantly comes through for me, and is the reason all of my purchasing inquiries start with blah
Please help.
I have tried the following methods
Tried saving without any delimiting to the Excel FIle
Changing the Query Results to add Quote Strings contianing list separators when saving .csv or copying result.
Your problem is that you have already used TextToColumn in this instance of Excel. Close Excel. Restart Excel. Execute the query in (I assume you mean) Sql Server Management Studio (AKA SSMS). Left-Click the square in the top left of the results to select all the rows in the query results windows. Then Right-click and select Copy With Headers. Then go back to Excel, select cell A1 and paste. The headers should take care of the column splitting.
Hth,
Ojf
Check if you are able to Export data using DTS Import Export Wizard of SQL SERVER 2012.
Try saving in both Excel(.xls) and Comma Separted file(.csv).
Related
I am currently using Oracle Apex to write queries and copy and paste the results into an Excel file. I have also used mySQL Workbench in the past.
My question is it possible to link a database to Excel and produce the results? For example in cell A1 I would want to type "select sum(sales) from accounts" and when I click enter, the result would appear in that cell after fetching the query?
I may be over thinking it or expecting something that is not possible. Any help is appreciated
You can connect your excel with a database and pull the data to the sheet, but writing queries in an individual column still need to figure out. In between, you can take a look at the ODBC configuration to connect excel with the database, Hope this will give some insights.
https://www.devart.com/odbc/mysql/docs/excel.htm
I have a table called tblAccounts whose contents will come from an excel spreadsheet.
I am using MS SQL Server 2008 (x64) on a Windows 8.1 (x64)
I tried using the SQL Server Import/Export Wizard but there is no option to choose an existing table but only an option to create a new one.
I tried using other methods such as OPENROWSETS
INSERT INTO tblAccount SELECT * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 12.0;Database=D:\exceloutp.xls','SELECT * FROM [Sheet1$]')
but gave me an error:
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.
Some research told me that it occurred because of a 64-bit instance of SQL server.
The problem is that this Excel data transfer to a SQL table must be accomplished using the SQL Import/Export Wizard only.
How can I import an Excel spreadsheet to an existing SQL table without creating a new one?
Some links I visited but was not able to help me resolve my problem:
How do I import an excel spreadsheet into SQL Server?
Fix OLE DB error
You can copy-paste data from en excel-sheet to an SQL-table by doing so:
Select the data in Excel and press Ctrl + C
In SQL Server Management Studio right click the table and choose Edit Top 200 Rows
Scroll to the bottom and select the entire empty row by clicking on the row header
Paste the data by pressing Ctrl + V
Note: Often tables have a first column which is an ID-column with an auto generated/incremented ID. When you paste your data it will start inserting the leftmost selected column in Excel into the leftmost column in SSMS thus inserting data into the ID-column. To avoid that keep an empty column at the leftmost part of your selection in order to skip that column in SSMS. That will result in SSMS inserting the default data which is the auto generated ID.
Furthermore you can skip other columns by having empty columns at the same ordinal positions in the Excel sheet selection as those columns to be skipped. That will make SSMS insert the default value (or NULL where no default value is specified).
Saudate, I ran across this looking for a different problem. You most definitely can use the Sql Server Import wizard to import data into a new table. Of course, you do not wish to leave that table in the database, so my suggesting is that you import into a new table, then script the data in query manager to insert into the existing table. You can add a line to drop the temp table created by the import wizard as the last step upon successful completion of the script.
I believe your original issue is in fact related to Sql Server 64 bit and is due to your having a 32 bit Excel and these drivers don't play well together. I did run into a very similar issue when first using 64 bit excel.
You can use import data with wizard and there you can choose destination table.
Run the wizard. In selecting source tables and views window you see two parts. Source and Destination.
Click on the field under Destination part to open the drop down and select you destination table and edit its mappings if needed.
EDIT
Merely typing the name of the table does not work. It appears that the name of the table must include the schema (dbo) and possibly brackets. Note the dropdown on the right hand side of the text field.
If you would like a software tool to do this, you might like to check out this step-by-step guide:
"How to Validate and Import Excel spreadsheet to SQL Server database"
http://leansoftware.net/forum/en-us/help/excel-database-tasks/worked-examples/how-to-import-excel-spreadsheet-to-sql-server-data.aspx
I often get requests that look something like this:
"Hey, can you reconcile this Excel spreadsheet with our database and
fill in the additional info for the ones you find? We also need to know
which ones are missing."
ID Name Client AdditionalInfo
------------------------------------------
234 John Client1
147 Mike Client2
546 Mary Client3
...
(Several hundred or thousand more rows)
Is there some way to take an Excel spreadsheet like that and join it to a SQL database within SQL Server Management Studio? I usually copy the ID to make a massive IN list, which is obviously far from ideal. Then I still have the task of lining up the data if I don't get a 1:1 match for every row.
I'm using SQL Server 2005 and Excel 2010.
I've tried to add an Excel spreadsheet as a linked server but querying it warned me that 'Ad Hoc Distributed Queries' are blocked and must be enabled. I'm not sure what negative implications enabling that may have, so I didn't go any further down that route.
My next thought was to use Excel formulas to make a SELECT [Col_A], [Col_B], [Col_C] UNION ALL for every single row in Excel, then copy that to SSMS to make a temp table I could join... but that still seems like a fairly messy and inefficient hack
You could import your Excel spreadsheet into a table in your database created specifically for that reason. In SSMS, right-click your database, go to Tasks->Import Data and choose Excel as your Data Source.
Excel can connect to Sql Server directly. Specifically, you want to use MS Query. This will allow you to join your Excel worksheet directly against a database using SQL.
I am trying to export 260+ column query to Excel from SSMS 2005.
When I finish up the wizard, I get the "Too many fields defined" error.
Is there any way of getting around this?
I suppose I can run that query via New Query and copy and paste to Excel but it doesn't copy over the column names.
Thanks
This seems to be a problem of your version of Excel other than SQL Server. If you have Excel 2003 (or an older version), then you only have 256 columns, so you won't be able to "get around this". For Excel 2007+, you shouldn't have a problem at all. By the way, you can still select all records after you run your query, right-click in the results, and select "copy with headers" to get the column names.
Good morning,
Does anyone know if there is an easy way I can use a SQL query in Excel to select specific data from an Excel spreadsheet without having to use VBA, Access, an SQL database or complicated Excel formula?
Thank you very much.
Use Microsoft Query.
I don't have Excel 2010 at the mo. In Excel 2007:
Ribbon: Data, From Other Sources (Get External Data From Other Sources), From Microsoft Query, Choose Data Source (dialog), Databases (tab), Excel File* (listbox), Select Workbook (dialog), browse for file, step through Query Wizard (dialog), at finish choose, View or edit query in Microsoft Query, click SQL (toolbar button) and there you can edit the query or change it entirely.
From a program you can use Jet SQL to query an Excel file.
From within Excel, I don't think you can use Jet SQL.