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.
Who is Participating?
Scott PletcherSenior DBACommented:
UPDATE table
SET col = REPLACE(col, ' N''GA\GA\', ' N''GA\')
WHERE col LIKE '% N''GA\GA\%'
export rows to xls and use replace with function to change the text. Afterwards import back to SQL.

tbailey2011Author Commented:
This is something that has to be automated everyday thru a sql query or that would work.
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,'')
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.