Using in Excel: Get Data>Other sources>Microsoft Query I had a table getting data from our company ERP system (ODBC).
I have a table in Excel and then I click in Excel: Data>Queries&Connections>Properies>Connection Properties>Definition and in "Command text" i put this simple SQL command:
SELECT F4111.ILLITM, F4111.ILTRQT/1000, F4111.ILTRUM, F4111.ILDGL, F4111.ILGLPT, F4111.ILDCT, F4111.ILUNCS, F4111.ILPAID, F4111.ILDOC, F4111.ILMCU
FROM RBGDC0P2.UREEUPBD.F4111 F4111
WHERE (F4111.ILLITM IN ('XXXXXXX', 'YYYYYYY')) AND (F4111.ILDCT LIKE '%AA%')
XXXXXXX and YYYYYYY are my input codes, which I need some data for them. 'F4111' is a table, ILLITM is my column from ERP database.
I can put ? to open a parameter and connect in to particular cell in Excel, and then I can simply change this cell in excel and refresh a table a have output for different input codes.
My question is: I want to have more parameters, like I put in excel column with 100 input codes and I need output for them by refreshing my table query. I can do it for one or few inputs by putting '?', but how can I do it for more?
Related
I have a field in Excel with comments. People enter data with line breaks in a cell (ALT + ENTER).
Is there a way via Excel VBA to import this via ADODB to SQL Server 2016, so I can also retrieve it again as multiline from the database?
An example: in Excel I have a multiline cell with value:
TEST
TEST
TEST
When I retrieve it again via the database it will show TESTTESTTEST, I would like to show the same as in Excel.
I tried both
rs![comment] = cell value
and
t-sql (simplified): insert into comment_table (comment) VALUES cell value
In both cases when I retrieve the data, I only get one string like in the example.
Hope somebody has an idea to solve this.
Already found the solution.
Field has to be of type nvarchar. If I query the table in SQL Server, I only see one string.
TESTESTTEST
If I for example retrieve it in Excel in a pivot and set the field to wrap text, it will apply the line breaks again.
There's an SQL database that I would like to query through excel without having to pull the entire SQL database into excel (5Million + rows). I have established the connection in excel. The values that I will be using to query the SQL Database are variable (typically around 150-200 cells).
End Result: The variable cells in excel are all in column A, I would like to query the Column A SQL values to retrieve the Column B SQL value and pull them back into excel. I know I could download the whole SQL database into excel and do a vlookup but my excel file will undoubtedly crash with all the SQL data.
Does anyone know where I should start? Would this best be resolved through VBA code or the advanced editor directly in excel?
Cheers,
Brandon M
You can include "?" in the query text of your connection. The first time you run the query, Excel will ask you what each of the "?" references. You can then change the values in those cells, and refresh the connection to use those new values.
Your situation is a bit unclear to me.
Do you want to perform "Select * from table where column in (Cell A)"? and then to print into Cell B?
If yes, you can use VBA code to build your SQL query and select the data.
If you don't want to use VBA, you can use some cell concatenation to build the query and can pass the query to SQL.
I have created a simple form in Powerapps which has a text input field called name and a data table which shows a list of all customers from a table called customer in a SQL Server database and I have also added a button labelled "Go" on the form.
What I want to do is:
See a blank data table when I first open the form
I would enter a customer name in the name text input field
Click the "Go" button and then the value from the name field will be passed to the SQL Server database in a query which only returns
the records which have the same name
Display the results of the query in the data table.
How can I do this?
Thanks
Assuming you've been able to correctly add your on-premise SQL server as a data source:
You'll want to use a combination of Collect() and Filter()
Assign your user input to a variable using (this isn't strictly necessary)
GetContext({UserVariable: TextInput.Text})
Use a combination of Collect() to store the data you pull from MSSQL, and Filter() to, well, filter the data.
Collect(AppStorageTable1, Filter('[dbo].SqlTable]', ColumnName1 = UserVariable))
If you assign AppStorageTable1 as your data source for your data table, it should now appear. (Note, you'll have to declare/create it before it will appear as an option, but once you've used the name in Collect() it will appear as a data source).
EDIT: The term you likely were looking for is "delegable", a quick search will yield a few articles about it. The "Filter" function will pass the work off to your SQL server, so your app won't be responsible for processing/filtering the data.
I have created an MS Access Form, an MS Access Query and a table depend on an excel file.
The form is named CheckForm and consists of a textfield for serialno, a search button (which has a makro to run a query) and a few fields with information, that should be filled by the query:
The query is named assets_ALT Abfrage - Serialno and looks as follows:
SELECT Assets_ALT.STREETADDRESS, Assets_ALT.FLOOR, Assets_ALT.ROOM, Assets_ALT.DEPARTMENT, Assets_ALT.ITC_NAME, Assets_ALT.ASSET_USER_NAME, Assets_ALT.PERSONID, Assets_ALT.COMPUTER_NAME, Assets_ALT.CATEGORY, Assets_ALT.MANUFACTURER, Assets_ALT.PRODUCT, Assets_ALT.MODELL, Assets_ALT.SERIALNUM, Assets_ALT.MAC_ADDRESS
FROM Assets_ALT
WHERE (((Assets_ALT.SERIALNUM)=[Formulare]![CheckForm]![SearchSerialNo]));
The table with information, on which the query is built looks like this:
When entering a serial no into the form like F7D5H92, clicking the Suchen-Button, the form should be filled with the data from the query.
But it does not, instead the query is being opened (and showing no result):
New to this site, but may be able to assist. First, you'll want to create a table by selecting 'External Data' and using the 'Linked Table Manager' to connect your Access program to the external Excel file and add all fields from the file. Use the Seriennummer as the primary key to ensure there is only one listing for the seriennummer.
Once connected you will need to create a query that has the criteria that refers to the 'Seriennummer' textbox to link the file with your form. For example, set the query criteria for that field to 'Like "" & [Forms]![Search]![Search2] & ""' if you form was named 'Search' and your textbox was named Search2. Then add a command button to your form and select the query to link the button to the query. Once you enter a serial number in the form and click the button, it should pull up the correct values on your form for that line item.
I have an SQL query that returns several things, including the date and time that an email was sent, as well as the body of that email. However, when I copy and paste the data to Excel, the body of the email does not stay in one cell, but takes up several cells, many times spanning several rows.
I have not used text-to-columns recently.
Does anyone know how to remedy this?
Thanks!
If you import data from 'Data' -> 'New Query' -> 'From Database' -> 'From Sql Server database' -> Provide your server name, database name and sql query to import data into excel, will get single attribute values to single column in excel