incubi Posted June 11, 2009 Share Posted June 11, 2009 The data tables I have to work with have white spaces in some fields and if I do a query with a WHERE ='1234" if fails because the queried value looks like this " 1234". So I need to trim out the spaces before the WHERE test. The only option I see is to use StringStripWS but I don't understand how to use that in the query with AutoIT. Access for example is easy SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num])) ="1234")); But that seems to fail using AutoIT and StringStripWS in place of Ltrim Any help would be great! Thanks, Incubi Link to comment Share on other sites More sharing options...
martin Posted June 11, 2009 Share Posted June 11, 2009 The data tables I have to work with have white spaces in some fields and if I do a query with a WHERE ='1234" if fails because the queried value looks like this " 1234". So I need to trim out the spaces before the WHERE test. The only option I see is to use StringStripWS but I don't understand how to use that in the query with AutoIT. Access for example is easy SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num])) ="1234")); But that seems to fail using AutoIT and StringStripWS in place of Ltrim Any help would be great! Thanks, IncubiThis is just a guess since I know nothing about sql. Maybe you could have SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE co.[co-num] IN " 1234"; where there ar more leading spaces in " 1234" than you ever expect. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Valuater Posted June 11, 2009 Share Posted June 11, 2009 (edited) I was thinking more like if the value can be captured in a variable, which it appears it can be. $Data = SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num])) If StringStripWS($Data) = "1234" Then ; do something EndIf .... BUT, I have no clue about sql either 8) Edited June 11, 2009 by Valuater Link to comment Share on other sites More sharing options...
incubi Posted June 11, 2009 Author Share Posted June 11, 2009 I think both ideas will work but in each case the query would have to search through a lot more records until it finds the right one and with a table with 20k + records in it that could take a while. For example in Access if I add the spaces to the number it takes 5x as long to get the hit, whereas if I trim the field before the WHERE test its fast. Thanks, incubi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now