Avatar of savache27
savache27 asked on

Trim characters in sql server 2000

Hi, I have a temporary table in sql server 2000. Sample data:

Course                              Email
20082.CIS.2010.01N      someemail@hotmail.com                  
20082.MATH.2030.01N  person2@hotmail.com

I was wondering if there is any way I can use query analyzer to remove the 20082 and the @hotmail.com  from each column. Any help would be greatly appreciated.          
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Mark Wills

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Aneesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
YZlat

use REPLACE function
YZlat

SELECT REPLACE('20082.CIS.2010.01N','20082.','');

SELECT REPLACE('someemail@hotmail.com','@hotmail.com','');
ASKER
savache27

Thank you so much for the help! I really do appreciate it.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Mark Wills

Yep, try this...


UPDATE MyTable  SET Course = REPLACE(Course, '20082.', '') where Course like '20082.%'

UPDATE MyTable  SET Email = REPLACE(Email, '@Hotmail.com', '' ) where Email like '%@hotmail.com%'

Mark Wills

Of course the update will permanantly remove them... and you could simply use it in a view or the select by using the replace directly and preserve the original data...
Mark Wills

Sorry guys, been typing away for a few hours and did not even notice that is had been answered already :)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.