February 17, 2016 at 2:16 pm
SUBSTRING(PAYROLL_EMP.WEBADDR, - 1, CHARINDEX('@', PAYROLL_EMP.WEBADDR) + 1) AS USERNAME,
Example:
Column PAYROLL_EMP.WEBADDR contains value jdoe@servercentral.com
The above statement returns jdoe as USERNAME
Is there a way to have JDOE returned in UPPERCASE
February 17, 2016 at 2:22 pm
Typically I would suggest doing formatting at the presentation layer, not the database layer, but if you need to do it in the query, then you can just make the SUBSTRING the input to the UPPER function (https://msdn.microsoft.com/en-us/library/ms180055.aspx.
Cheers!
February 17, 2016 at 2:22 pm
Use the UPPER function.
-- Itzik Ben-Gan 2001
February 17, 2016 at 2:41 pm
SUBSTRING(UPPER(PAYROLL_EMP.WEBADDR, - 1, CHARINDEX('@', PAYROLL_EMP.WEBADDR) + 1) AS USERNAME,
SQL returns this error...
Msg 174, Level 15, State 1, Line 30
The upper function requires 1 argument(s).
February 17, 2016 at 2:45 pm
You don't have the correct scope for the UPPER.
At any rate, it's simpler to do it the other way around, since you already have the SUBSTRING working. Just take the SUBSTRING and pass it to UPPER, instead of doing an UPPER and then taking a SUBSTRING.
UPPER(SUBSTRING(PAYROLL_EMP.WEBADDR, - 1, CHARINDEX('@', PAYROLL_EMP.WEBADDR) + 1))
Cheers!
February 17, 2016 at 2:57 pm
Thank you Jacob! Appreciate your help! Kind regards, Bob
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy