I have MS Access query and try to convert to SQL Server query.
Please someone can help me.
UPDATE AppReferrals
SET AppReferrals.DeviceID = CLng(Val(Left(IIf([AppReferrals].[DeviceID] Like '0',[AppReferrals].[ActionID],[AppReferrals].[DeviceID]),9)));
Good I think I'm very old
I worked with Visual basic in my first job 20 years ago
basically what you are doing is taking a value "first 9 digit" (DeviceID) and this is null the alternative (ActionID) and converting it to an Long value
using the following functions
CLng
Val
Left
IIf
Like
Example in visual basic net the function
Related
I am trying to figure out how MS access calculates the following query where contractualDate and ContractualTime are both datetime:
(Max(([contractualDate]+[ContractualTime]))-Min(([contractualDate]+[ContractualTime])))*25,0) AS TrailerCost
The closest I could think of using SQL is
Datediff(m,Min(([contractualDate]+[ContractualTime])),Max(([contractualDate]+[ContractualTime])))*25 AS TrailerCost
This gives me results that differ from the first VBA code, what did I do wrong here?
Facing very strange issue regarding PL/SQL function call from VBA and Output of same on Oracle SQL Developer. Both seems to vary by a lot. Please go through the attached screen shots. 1st Image shows the VBA output.
Here is the output which I get on ORACLE SQL Developer
More strange thing here is, This error I am facing only for few FSYM_IDs not all. For others its coming very much precise.
I did see the following question
Similar Question
There user had mentioned about hash joins but I haven't used any sort of hash joins at all.
I have used ADO and Range.CopyFromRecordSet to fetch data into excel. Executed the same exact query which is
select FSYM_ID, CURRENT_FY, ROUND(VALUATION_PB_HIGH,0), ROUND(VALUATION_PB_LOW,0) from table(PRICE2BV('07BR8Q-R'))
into excel and oracle sql developer.
I have updated the SQL Developer screenshot. Difference is in the particular years high and low value. I have highlighted that in the SQL developer output.
Additional things about Oracle PL/SQL functions are
Function returns data from global temporary table.
Variables used are of type number or varchar only.
Input to the function is identifier for the company only.
I have tried to retrieve output using table also but no use.
I have even tried the approach of GetRows mentioned on following link.
SQL Query output in VBA is different than in SQL Oracle
One thing I observed regarding recordset is that==> Values are different when I query from VBA and Oracle SQL Developer.
Please help me regarding same.
When trying to do an SQL injection on an Oracle SQL database I have the problem that most of the examples in the tutorials do not work. I already found out that I only can use CASE WHEN a THEN b ELSE c END instead of normal if statements.
The question I have now is how do I get time delay into the injection? Benchmark() and sleep() do not work either.
I already now that the table is named "flag" and the field name I want to read out is named "password".
My only information i get from the database is the time it needed to execute my input (or query since I bypass the input to inject SQL)
I found the following SQL statement on the web at SQL Injection Tutorial
select dbms_pipe.receive_message(('a'),10) from dual;
I am not certain I should be participating in this sort of thing, but since I found it with my first Google Search, I will go ahead and post it.
I tested it and it delayed the result by 10 seconds.
I'm trying to filter results from a Query i have created in Microsoft Query to pull data from a database into my Excel sheet. Specifically I'm trying to filter out based on the nth character of a string.
I can easily filter out the based on the first char:
SOPOrderReturnLine.ItemCode Like 'A25%'
But I have no idea how I could filter to show only entries where the 10th char = "A". I'm sure I have to use a Substring function, but it's not familiar to me and I'm struggling to get it to work.
Try to edit your sql query and enter the following statement:
select * from SOPOrderReturnLine where substring(SOPOrderReturnLine.ItemCode,10,1) = 'A';
The statement should work for a MySql database as well as for an Sql Server in the background; (I've tested it with an MySql database).
Hope this helps.
In MSQuery (Jet under the covers, I think), the function is Mid.
SELECT * FROM tblLocation WHERE (Mid(LocationName,2,1)='e')
to find a lower case 'e' in the second location.
I assume when you say MS Query, you are running a query against a DBMS (SQL Server or some other via ODBC).
The use of substr, substring or mid should work, depending on which DBMS. That said, unless you're using MS Access, I think most DBMSs will support the underscore character as "any single character." It might even work in Access, but I don't know for sure. Therefore, I think in addition to the suggestions you've gotten, this will also work in most cases:
SOPOrderReturnLine.ItemCode Like '_________A%'
If you want to use substring, don't hold me to these, but I think:
Oracle / DB2 / SQLite - substr
Microsoft SQL Server / Sybase / MySQL - substring
MS Access - mid
PostgreSQL -substr or substring
Using MS Office+VBA (or, sometimes, Visual Studio 2010) I am looking for a way to query Excel-Files using only SQL Query, similar to this way of querying a textfile:
SELECT * FROM [Text;DATABASE=L:\Testfiles].test1.csv
As a result I would expect something like:
SELECT * FROM [Excel File=L:\Testfiles\test2.xls].[sheet1$A1:B1000]
I am not looking for a way to query Excel-Files with SQL and a ADODB-connection string (as depicted on connectionstrings.com or here on so.com), since I want all information regarding the data source inside the actual SQL-Code, and not split up between SQL and the connection setup in VB/VBA.
Any hints would be greatly appreciated.
Regards
Martin
You can use FROM clause like this:
FROM [sheet1$A3:E22] IN 'C:\path\MyFile.xlsx' [Excel 12.0;HDR=YES;IMEX=0]