Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server SQL Server-删除/删除表记录的特定部分_Sql Server - Fatal编程技术网

Sql server SQL Server-删除/删除表记录的特定部分

Sql server SQL Server-删除/删除表记录的特定部分,sql-server,Sql Server,我有一个SQL Server 2012,表中有2.047条记录,我称之为dbo.tblTest。 所有记录都依赖于以下公式: SomeTextX.pdd_openslam_SomeTextY 现在我要做的是删除\u openSlam\u SomeTextY 所有记录都变成SomeTextX.pdd 非常好, Konstantinos因此,如果我理解正确,您可以将charindex与左一起使用: select left(yourfield, charindex('pdd_', yourfield

我有一个SQL Server 2012,表中有2.047条记录,我称之为
dbo.tblTest
。 所有记录都依赖于以下公式:

SomeTextX.pdd_openslam_SomeTextY
现在我要做的是删除
\u openSlam\u SomeTextY
所有记录都变成SomeTextX.pdd

非常好,
Konstantinos

因此,如果我理解正确,您可以将
charindex
一起使用:

select left(yourfield, charindex('pdd_', yourfield) + 2)
from yourtable
如果您确实想更新数据,这将起作用:

update yourtable
set yourfield = left(yourfield, charindex('pdd_', yourfield) + 2) 

嗯,什么?我不确定我是否理解你的问题。示例数据和期望的结果总是有用的…抱歉,我猜我使用了一些编辑器不允许显示的符号,问题不容易理解。你现在可以检查吗?不理解你的问题hi-假设我们有2条记录->A)rec1.jpg.sometext B)rec2.jpg.someOtherText//是否仍有删除.jpg之后的部分的方法,因此记录将是A)rec1.jpg B)rec2.jpg谢谢你想从文件扩展名中删除的部分总是相同的吗?我正在尝试,让你试试看知道!谢谢