Fetching Query Result Directly Into an Excel Cells - sql

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

Related

SQL Export to multiple Excel Worksheets

everyone!
I'm mostly just curious if this can be done, but here we go:
I have a query I run about once a month that ends up going into an Excel Worksheet. It creates a list of businesses and representatives. Now, I know that you can create SQL code that exports query results directly to a worksheet (see Export SQL query data to Excel), but I want to know if I can take the result, and export it using SQL to multiple worksheets based on representative? So that each rep gets a worksheet of just their businesses?
I'm thinking it would involve some kind of loop (see SQL Server FOR EACH Loop), but I just can't find anything definitive.
Thoughts?
Thanks!
You can create an SSIS package to achieve that. Write a different query for each rep and export the results into an Excel.

Save Results of a SQL Query to an Excel File

I have an SQL Query I'm using to Pull Beds by Unit and the related Number of Beds in Use and Available.
What is the SQL Syntax to have the results of the query save to an excel file (existing or new).
Please Note: I have been searching and I can't believe this isn't easy to figure out. Lots of people seems to use other tools but I want to do it in SQL Stored Procedure - Is this possible?
Thanks so much for your help!
The easier way to do this is from Excel, utilize a connection to your SQLDB and then pull the data into excel, that is the most efficient way to do it.

SQL Server 2012 to Excel 2010 Copy and Paste

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).

Update sql table from excel

I need users to insert excel data into a sql table on a continuous basis.
They are not sql users, they are barely excel users.
The sprreatsheet is simple, 5 columns, less than 500 rows at a time and all into a single sql table.
In a perfect world they open and update excel and in one or two clicks get a message that says Success.
I am open to any approach.
I have used the import wizard with success, i can write vba code and some sql.
What I don't know how to do is to get a user to inseert excel into a sql table without risking the entire database to complete distruction.
stay well,
michael
you should build a small interface program that the users would update. You can then control it all you want, and update the database as desired, based on their input. Add a single "SAVE" button to save their input.

SSMS: query export to Excel

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.