Link to home
Start Free TrialLog in
Avatar of tbailey2011
tbailey2011

asked on

Replace certain text within row

I have a table with multiple rows like this:
if not exists (select * from dbo.sysusers where name = N'GA\ggalligan') Exec sp_grantdbaccess N'GA\GA\ggalligan', N'GA\ggalligan'

I need to remove the first GA\ where it says GA\GA\ggalligan.  All the rows are different lengths, so it always can't start in the same place. This needs to be an update statement.  Any help would be much appreciated.
Avatar of exile1337
exile1337

export rows to xls and use replace with function to change the text. Afterwards import back to SQL.

Avatar of tbailey2011

ASKER

This is something that has to be automated everyday thru a sql query or that would work.
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would run this as a select to make sure it gives you the desired results first.

UPDATE YourTable
SET YourFieldName = STUFF(YourFieldName,CHARINDEX('GA\',YourFieldName),3,'')