简体   繁体   English

MS SQL Server中的Charindex

[英]Charindex in MS SQL Server

There was a problem i had to find the solution for which was : 1) Ignore data breaks where the same PB SAP ID is present in Avaloq data multiple times and same value is present in CRM. 我必须找到一个解决问题的方法是:1)忽略数据中断,其中Avaloq数据中多次存在相同的PB SAP ID,而CRM中存在相同的值。 The PB SAP ID is a field which should be unique. PB SAP ID是一个唯一的字段。 Avaloq and CRM are two different systems that store similar data. Avaloq和CRM是两个存储相似数据的不同系统。

My colleague suggested the following SQL was the solution and it seems to work, but i do not understand how this is working in this case. 我的同事建议使用以下SQL作为解决方案,它似乎可以正常工作,但在这种情况下,我不知道它是如何工作的。 Can someone please explain from the SQL below : 有人可以从下面的SQL中解释一下:

PS cpp = crm system and ap. = Avaloq PS cpp = crm systemap. = Avaloq ap. = Avaloq

where  charindex(cpp.PbSapId,ap.Pb_SapId) =0

Charindex returns the position of a substring within a string - in this case, the character position of the ap.Pb_SapID that contains the cpp.PBSapId. Charindex返回字符串中子字符串的位置-在这种情况下,即包含cpp.PBSapId的ap.Pb_SapID的字符位置。 The 'where' '= 0' ultimately means you a searching for records where the ID is not within the ID of the other table. “ where”“ = 0”最终意味着您正在搜索ID不在另一个表的ID内的记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM