I have a database of vin numbers for vehicles.
* as a character as it could be any number or letter. however some are specific.
I am now looking for a string that would allow
* in the table to be a wildcard.
E.g. if someone searched
Task it would find
T*sk in the database.
Best How To :
Not sure what SQL server you're on, but hopefully this works on any (tested on MSSQL).
If you look at the documentation for LIKE, you see that the wildcard you need is
_ (underscore). Operators in SQL, in general, can be used both ways (i.e. both
field LIKE constant and
constant LIKE field will work). So, without knowing you table structure (which would have been quite helpful actually), your query will look something like this:
SELECT * FROM Vehicles WHERE 'V123456789' LIKE REPLACE(Vehicles.Vin,'*','_')
I'm not sure about the performance here, but hopefully this should get you started in the right direction.