sql server - sql replace all characters between two strings -



sql server - sql replace all characters between two strings -

i trying figure out way update / replace text between 2 strings.

for instance need able update field , replace what's in between next script tags leaving text before opening script tag untouched.

i want maintain string<script type="text/javascript" language="javascript">********</script>

i suppose replace not going work text in between script tags vary. there type of wildcard?

update products_joined set techspecs = replace (cast(techspecs nvarchar(max)), '<script type="text/javascript" language="javascript">********</script>', '<script type="text/javascript" language="javascript">new text</script>' )

updated: @parkyprg reply works doesn't replace closing </script> tag. end this.

i want maintain string new text</script>

how remove closing script tag well?

update products_joined set techspecs = replace(cast(techspecs nvarchar(max)), substring(cast(techspecs nvarchar(max)), charindex('<script type="text/javascript" language="javascript">',techspecs), charindex('</script>',cast(techspecs nvarchar(max))) - charindex('<script type="text/javascript" language="javascript">',techspecs) ),' new text')

declare @opentag varchar(100) set @opentag = '<script type="text/javascript" language="javascript">' update products_joined set techspecs = stuff(techspecs , charindex(@opentag, techspecs ,1) + len(@opentag), charindex('</script>',techspecs ,1)-(charindex(@opentag, techspecs ,1) + len(@opentag)), 'new text')

sql sql-server sql-server-2000

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -