sql语句把字段中的某个字符去掉

时间:2021-04-14 05:44:14

sql语句把字段中的某个字符去掉

update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),'http://demo.m-school.net','')

例如:

update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),'http://192.168.2.180','')
update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),'http://zpzx.m-school.net','')
update Homeworks set Accessory=replace(Cast(Accessory as varchar(8000)),'http://192.168.2.180','')
update Homeworks set Accessory=replace(Cast(Accessory as varchar(8000)),'http://zpzx.m-school.net','')
update OpenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),'http://192.168.2.180','')
update OpenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),'http://zpzx.m-school.net','')
update OpenCourses set Audio=replace(Cast(Audio as varchar(8000)),'http://192.168.2.180','')
update OpenCourses set Audio=replace(Cast(Audio as varchar(8000)),'http://zpzx.m-school.net','')
update ListenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),'http://192.168.2.180','')
update ListenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),'http://zpzx.m-school.net','')
update ListenCourses set Audio=replace(Cast(Audio as varchar(8000)),'http://192.168.2.180','')
update ListenCourses set Audio=replace(Cast(Audio as varchar(8000)),'http://zpzx.m-school.net','')

老师,学生,家长头像:

update Sys_User set Portrait=replace(Portrait,'http://zpzx.m-school.net','')
update Students set Portrait=replace(Portrait,'http://zpzx.m-school.net','')
update Parents set Portrait=replace(Portrait,'http://zpzx.m-school.net','')