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

Update using substring and charindex 1

Status
Not open for further replies.

epkiran

Programmer
Joined
Jun 26, 2001
Messages
7
Location
SE
Hi, I am trying to update a part of an column containing emailadresses, and I got a tip using this:


UPDATE Student
SET EMail = SUBSTRING(EMail, 1, CHARINDEX('@', EMail) + 1) + [new.se]
WHERE (EMail LIKE [%old.se])

But I get the error message

Invalid column name 'new.se'

Is there something wrong or missing ?
new.se is not a column name, it should be the new domainadress...

I have been looking for how to use substring and charindex but I have not found any useful information...

 
Hi there,
Try this
--------------------------

UPDATE Student
SET EMail = SUBSTRING(EMail, 1, CHARINDEX('@', EMail) + 1) + 'new.se' WHERE (EMail LIKE '%old.se')

--------------------------
Hope this will solve your problem.
 
eh, just one problem left.....
the first letter in the old adress is left,
so now the new adress is onew.se....
 
hepp, I removed +1 and it was OK.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top