这是我的专栏,名为Sets。
我的专栏:
count
预期
{C=Pass, D=Fail, E=Pass, F= Pass, G=Pass}
{C=Pass, D=Fail, E=NoApplication}
我希望删除我的专栏中的“失败”。 请帮忙。
答案 0 :(得分:0)
您可能正在寻找更新命令
UPDATE TableName
SET Name = CASE WHEN CHARINDEX('=Fail,',Name ) > 1
THEN STUFF(Name,CHARINDEX('=Fail,',Name)-1,LEN('=Fail,')+1,'')
ELSE Name
END
答案 1 :(得分:0)
你可以试试这个
更改表格中的值。只需将DECLARE @tbl TABLE(YourColumn VARCHAR(100));
INSERT INTO @tbl VALUES
('{C=Pass, D=Fail, E=Pass, F= Pass, G=Pass}')
,('{C=Pass, D=Fail, E=NoApplication}');
WITH Casted AS
(
SELECT CAST('<x>' + REPLACE(SUBSTRING(t.YourColumn,2,LEN(YourColumn)-2),', ','</x><x>') + '</x>' AS xml) AsXml
,t.YourColumn AS OldValue
FROM @tbl AS t
)
,UpdateableCTE AS
(
SELECT '{'
+ STUFF((
SELECT ', ' + a.value('.','nvarchar(100)')
FROM Casted.AsXml.nodes('/x') AS A(a)
WHERE RIGHT(a.value('.','nvarchar(100)'),4)<>'Fail'
FOR XML PATH('')
),1,2,'')
+ '}' AS NewValue
,OldValue
FROM Casted
)
UPDATE UpdateableCTE SET OldValue=NewValue;
SELECT * FROM @tbl;
替换为您实际的表名称,将YourColumn替换为列名称。 关注真实数据!
function repl() {
database.replicate(`http://${SG_URL}/${DB_NAME}`, DB_NAME, REPLICATION_OPTIONS)
.then(res => {
console.log('replicate:' + util.inspect(res, {showHidden: false, depth: null}) )
})
}
repl()
字符串被拆分为其元素。然后重新连接,没有“失败”的那些。