Reputation: 6159
I have a post deployment script in my .NET project.
At deployment I want to update some rows based on some conditions.
This is what I have so far:
DECLARE @BRANDS NVARCHAR(500) = 'http://example.com/';
UPDATE [ServiceVersion]
SET [ExternalUrl] as = CASE
WHEN (
SELECT [ExternalUrl]
FROM [ServiceVersion]
WHERE [GatewayPath] = '/proxy/brands'
) != @BRANDS
THEN @BRANDS
END
WHERE [GatewayPath] = '/proxy/brands'
If the row is not equal to my variable, than it updates it. Else it does nothing.
What I want to do more than that, is to add another condition, like x !=BRAND && string does not contain "abc" update.
But how do you add another condition in a CASE that checks for substring?
Upvotes: 0
Views: 303
Reputation: 745
Try this...
DECLARE @BRANDS NVARCHAR(500) = 'http://example.com/';
UPDATE [ServiceVersion]
SET [ExternalUrl] = @BRANDS
WHERE
[ExternalUrl] != @BRANDS
AND [ExternalUrl] not like '%abc%'
AND [GatewayPath] = '/proxy/brands'
Hope this help!
Upvotes: 1