Reputation: 21
Device_Users
I only want administrator in this field what update query should I run
Upvotes: 0
Views: 80
Reputation: 12317
Maybe this is good enough:
update Device_Users
set field = 'Administrator'
where field like '%Administrator'
Upvotes: 0
Reputation: 469
You can use CHARINDEX practical because you can set a starting point for the search in the string, useful if you know how long is your prefix (I have put 6 but it depends on your data)
UPDATE table SET column = 'Administrator' WHERE CHARINDEX('Administrator',column,6) > 0
If needed you can refine the WHERE clause to make sure you're not replacing entries which have something after Administrator
AND LEN(column) = CHARINDEX('Administrator',column,6) + LEN('Administrator')
Upvotes: 0