Add apex SQL Server with replace

gcxthw6b  于 2023-02-28  发布在  SQL Server
关注(0)|答案(1)|浏览(157)

I need to add an apex in a specific point of a formula in SQL Server, in a lot of rows. Can I do this with a script? I tried but SQL doesn't understand apex "like a string"

CAMPO XYZ:

X NOT IN (SELECT A FROM #ABC# WHERE APPLE = 'NO')
AND ISNULL(ISNULL(SUNNY,'),'NO') <> 'YES'  
AND (VEG = 'CARROTS')

My idea:

DECLARE @a varchar(100)
DECLARE @b varchar(100)

SET @a = 'SUNNY,'';
SET @b = 'SUNNY,''';

UPDATE A 
SET A.XYZ = REPLACE(A.XYZ, @a, @b) 
FROM...

I need to replace the wrong one apex with double apex for that ISNULL .

Can you find the correct syntax?

bvjxkvbb

bvjxkvbb1#

Apex, i guess you mean quote? Every quote must be quoted again, so something like this should work:

DECLARE @a  varchar(100)
DECLARE @b  varchar(100)

SET @a = 'SUNNY,''';
SET @b = 'SUNNY,''''';

UPDATE A SET A.XYZ= REPLACE(A.XYZ,@a,@b) FROM...

相关问题