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.
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.
export rows to xls and use replace with function to change the text. Afterwards import back to SQL.
ASKER
This is something that has to be automated everyday thru a sql query or that would work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would run this as a select to make sure it gives you the desired results first.
UPDATE YourTable
SET YourFieldName = STUFF(YourFieldName,CHARIN DEX('GA\', YourFieldN ame),3,'')
UPDATE YourTable
SET YourFieldName = STUFF(YourFieldName,CHARIN