Southern_Gentleman
asked on
SQL Server Express Expression
I'm using SQL Server 2012 Express and I'm wanting to create a query that uses an expression. I actually built it in MS Access but need to convert it to SQL Server. I have a description field from a table that I'm wanting to trim text. Here is my expression that I'm having a hard time converting. I believe that TRIM doesn't exist in SQL Server and that you have to LTRIM and RTRIM.
Trim(Left(Replace(Trim(Rig ht(Replace ([tblorder detail]![d escription ],",",REPT (" ",255)),255)),"-",REPT(" ",255)),255))
This expression takes the following text example and gives the result of what I want:
Example #1: Men's Shirt, 100% Cotton, Dark Navy Body, White Stitching - XL
Result: Dark Navy Body, White Stitching
Example #2: Men's Shirt, 100% Polyester, White Body - LG
Result: White Body
So in theory, I need to take the second comma and display all the text before the dash and all the text after the second comma.
Trim(Left(Replace(Trim(Rig
This expression takes the following text example and gives the result of what I want:
Example #1: Men's Shirt, 100% Cotton, Dark Navy Body, White Stitching - XL
Result: Dark Navy Body, White Stitching
Example #2: Men's Shirt, 100% Polyester, White Body - LG
Result: White Body
So in theory, I need to take the second comma and display all the text before the dash and all the text after the second comma.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome guys.
Open in new window