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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select part of a record/field - trim??

Status
Not open for further replies.
Jan 23, 2003
26
US
Hi,
I'm trying to Select part of a field in SQL. In my record set I have all records starting with SF/username. I'd like to create a Select statement to display on the username, not SF/. What would my syntax be?

Instead of SF/username. I'd like to show username.

Any help would be appreciated. Thanks.
 
Hi swampboogie,
What do the numbers 4 and -3 stand for? Are they the length of the field?
 
4 if the position the substring will start from, the 4th character in the original string. The second part is telling it how many characters to count in the substring - the length of the overall string minus the 3 characters you don't need.
 
This is the query I want to use, but it only works for Access. How do I tweak this so Microsoft SQL can handle it?

SELECT MemberInventory.MemberInventory_ID, ProductSKU.SKUNumber, MemberInventory.InternalPartNumber, IIf(Len([InternalPartNumber]) > 1), [InternalPartNumber], [SKUNumber]) AS SearchField
FROM MemberInventory INNER JOIN
ProductSKU ON MemberInventory.ProductSKU_ID = ProductSKU.ProductSKU_ID


Basically what I want it to do is check to see if the string length of InternalPartNumber is > 1 or not null, and if those checks are both true, then display SKUNumber. Otherwise, show InternalPartNumber. How can I do that in SQL? Can I use the IIF function?
 
For SQL use a CASE statement instead of IIF

it is a good idea to start your own thread, and in the right forum so that you get the most help possible.

Transcend
[gorgeous]
 
Sorry .. this is the right forum, I just meant starting your own thread would help you out more :)

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top