Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Trim in Parameter Query

Status
Not open for further replies.

JackieEVSC

Programmer
Oct 27, 2011
8
US
We frequently have to retag computer equipment used by students. We have a SQL database that has a list of all asset numbers and associated serial numbers.

With older units, we can scan the serial number to get the asset tag (and visa/versa). With the new units, when we scan the serial number, we get a really long number (like 1S02DAS00100LR035QW2), but only need the last 8 digits (LR035QW2), which is what we have in the SQL database as the serial number.

For the life of me, I cannot seem to get the query to pull the associated asset tag number when scanning the serial number. How do I get the query to use only the last 8 digits of the input box to pull in the associated data from the SQL table?
 
Hi,

Certainly not with the Trim() function!

How about the Right() function?
 
Preferably MID() (replaces both LEFT() and RIGHT() functions, and easier to remember one function than 3)...

SELECT CASE LEN(strAsset)
CASE 20: MID(strAsset,12)​
CASE 8: MID(strAsset,1) '(or just strAsset)​
END SELECT

And wouldn't TRIM just be a non-risk, safety addition?
e.g. TRIM(MID(strAsset,12)) - in case the code contains an outer space?
(I don't know if a bar-code can contain an outer space).

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top