Created
February 17, 2016 16:12
-
-
Save oscarandreu/e9e8730f3360e309b8ca to your computer and use it in GitHub Desktop.
Replace part of a field and update the row
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;WITH CTE AS | |
| ( | |
| SELECT top 2 | |
| [Lab_ID] id | |
| ,replace(Lab_HtmlDefinition, 'data-pdnbind="src: resources/V1/products/{ean}_04;"', '') html | |
| ,CASE WHEN Lab_HtmlDefinition <> replace(Lab_HtmlDefinition, 'data-pdnbind="src: resources/V1/products/{ean}_04;"', '') THEN 1 ELSE 0 END WasReplaced | |
| FROM [dbo].[Lab_Pricelabels] | |
| WHERE --lab_customerId = 180211 and | |
| Lab_ID = 560589 | |
| ) | |
| --select count(*) from cte where Lab_HtmlDefinition like '%FOOOOOOOOOOOOOOOOOOOOOOOOOOF%' | |
| --select * from cte | |
| update lbl | |
| set lab_htmldefinition = html | |
| FROM dbo.lab_pricelabels lbl inner join cte ON id = Lab_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment