Data Parameter in Excel not working with Access Query Connection - excel

I have a connection to an Access DB query within Excel. The field in the Access query is an expression turning a field into a proper date. The problem that I'm having in Excel lies within passing the parameter from a cell containing the date that I want the query to run for. The results are either completely wrong or result in nothing. I have tried modifying the parameter cell to just about everything to no avail. I have tried the edit query option under view connection and when prompted to put in the value for the parameter, it actually returns the data I want. I would thing that this would be exactly the same parameter it would be grabbing from the formatted cell?
I have attached my connection's SQL command text below. And also an image with more detail and screenshots.
This is the command text from Excel containing my Where clause:
SELECT Query1.SETYPE, Query1.`SEORD#`, Query1.ORBILL, Query1.ORCUST, Query1.ORLDAT,
Query1.ORCONS, Query1.SESEV, Query1.CMTYPE, Query1.CMTEXT, Query1.ORDDATfix
FROM `C:\USERS\DRED\DESKTOP\ServiceFailures.accdb`.Query1 Query1
WHERE Query1.ORDDATfix =?

SELECT Query1.SETYPE, Query1.`SEORD#`, Query1.ORBILL, Query1.ORCUST, Query1.ORLDAT, Query1.ORCONS, Query1.SESEV, Query1.CMTYPE, Query1.CMTEXT, Query1.ORDDATfix
FROM `C:\USERS\DRED\DESKTOP\ServiceFailures.accdb`.Query1 Query1
WHERE (Query1.ORDDATfix>=?)
Apparently putting the clause in parenthesis fixed the problem.

Related

Search exact text in a string

I am querying a SQL Server DB. I have a field "Remarks" that contains values pipe delimited as such
59P|W26|W511|862|W51
I'm trying to search in this field for an exact match, for example in the above I just want to return W51 not W511. I thought contains would help but unfortunately the table is not full text indexed and I dont have the ability to change that. Any suggestions?
It looks like you can do this using sql server because it has a useful built in function. Check out https://www.sqlservertutorial.net/sql-server-string-functions/sql-server-string_split-function/

Can you make columns optional for SQL Insert Row in Azure Logic Apps?

I am using the Logic App designer on Azure. Added "SQL Azure - Insert Row" as an Action, it prompts me to insert values for the columns but all the columns are marked as required and it doesn't save the changes/sequence if a value is not entered there.
Is there anyway of bypassing this or making the columns optional?
I tried this previously, there was no way to make the columns optional but i figured a workaround.
First, in the designer put any value, then open Code view and look for the columns you don't need and just delete it from the JSON schema and hit save :)
that should do it for you, but next time you open in designer and try to edit you have to do this again.
let me know if it helps
Edited
I added a screenshot of the steps that i made while trying to replicate this. (note that your database schema should handle these null values for the columns, in my case the Guid had a default value of newid() and the other column allowed nulls). You always pass null to the columns, not passing values at all might make sense for columns that has values computed or has default values (like newid() uniqueidentifier or getdate() for created/modified time)

MS Access LIKE expression has issue when used as MS Excel data-source

I have created an MS Access 2013 query and within the query I have an expression that uses the LIKE operator. I then create an Excel 2013 workbook and select this Access database as a data-source and select the query that contains the LIKE expression. The problem is that it does not seem to like the LIKE expression when returning the data to excel. It shows correct results when running the query from inside Access.
So if I have an expression that looks like this
iif([CAR] like "*A*", True,False)
It will return all CARs in the table and show true or false depending on the string in the CAR field when running the query inside Access. But when setting this query as an Excel data-source, it returns only the results that result in false (no A in the CAR field string)
I know that Excel does not use the LIKE operator, but I thought that the query in Access produces the results and Excel just uses the results.
If you need clarification on the question please ask in the comments.
In Access SQL-89 mode, * is used as a wild card character to match any sequence of zero or more characters. SQL-89 mode is the Access default for the query designer and for queries run from DAO.
But Access also supports SQL-92 mode which uses % instead of * as the wild card. If you're using ADO to run your query from Excel, it is using SQL-92 mode.
There are at least 3 things you can do to get the results you expect in Excel:
IIf([CAR] Like "%A%", True,False) - Use this expression in your query to get your expected results in Excel. The downside is you may not see the same results when the query is run in an Access session.
IIf([CAR] ALike "%A%", True,False) - Alike (instead of Like) signals the database engine to expect % instead of * as the wild card, regardless of whether the query is run from SQL-89 or 92 mode. So this expression should give you the same result in both Access and Excel.
IIf(InStr(1, [CAR], "A", 1) > 0, True, False) - InStr doesn't rely on wild card characters so should give you the same results in both Access and Excel.

SSRS 2012 - Sending multiple values in parameter to main dataset

I have a report that is up and running but I need to restrict the data on a parameter that takes multiple string-valued staff codes.
I created a parameter called Practioner which is a text type, ticked on Allow Multiple values and also on Visible.
In the available values, I made this code come from the field called mbillaty from the dataset3 under the Get values from a query option. I've checked data3 is fine in SQL server.
3.Now, I've gone to my dataset1 where all the reporting data sits then put the parameter, with the name ? and =Join(Parameters!Practitioner.Value,", ") for the parameter value. Then in the query, in the where clause, I've put: ......mbility in (?)
What should this SSRS be interpreting as is : .......mbility in ('AAB','KKR','RDR'), if the user picked these three staffs.
When I run the report, it definitley works when I check one of the practioners, but as soon as I more than one, the report wouldn't run. It does not return any error, but just the header shows, which I think means that no data is found.
Experts, do you see where I've gone wrong with this?
Thanks
If you're able to create UDFs, this link might be helpful. How do I split a string so I can access item x?
The parameter would be parsed in the SQL/function, and SSRS would simple pass the concatenated string.

Excel: Use a cell value as a parameter for a SQL query

I'm using MS Excel to get data from a MySQL database through ODBC.
I successfully get data using an SQL query. But now I want that query to be parameterized.
So I wonder If it is possible to use a cell value (a spreadsheet cell) as a parameter for such a query.
For example, for this query:
select name from user where id=1
I'd like to get the id value from, say, cell D4 in the spreadsheet.
Is that the proper approach to parameterize a query? and how can I do it?
Thanks.
I had the same problem as you, Noboby can understand me, But I solved it in this way.
SELECT NAME, TELEFONE, DATA
FROM [sheet1$a1:q633]
WHERE NAME IN (SELECT * FROM [sheet2$a1:a2])
you need insert a parameter in other sheet, the SQL will consider that information like as
database, then you can select the information and compare them into parameter you like.
If you are using microsoft query, you can add "?" to your query...
select name from user where id= ?
that will popup a small window asking for the cell/data/etc when you go back to excel.
In the popup window, you can also select "always use this cell as a parameter" eliminating the need to define that cell every time you refresh your data. This is the easiest option.
queryString = "SELECT name FROM user WHERE id=" & Worksheets("Sheet1").Range("D4").Value
The SQL is somewhat like the syntax of MS SQL.
SELECT * FROM [table$] WHERE *;
It is important that the table name is ended with a $ sign and the whole thing is put into brackets. As conditions you can use any value, but so far Excel didn't allow me to use what I call "SQL Apostrophes" (ยด), so a column title in one word is recommended.
If you have users listed in a table called "Users", and the id is in a column titled "id" and the name in a column titled "Name", your query will look like this:
SELECT Name FROM [Users$] WHERE id = 1;
Hope this helps.

Resources