简体   繁体   中英

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. The PB SAP ID is a field which should be unique. Avaloq and CRM are two different systems that store similar data.

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. Can someone please explain from the SQL below :

PS cpp = crm system and ap. = 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. The 'where' '= 0' ultimately means you a searching for records where the ID is not within the ID of the other table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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