'SUBSTRING WITH CHARINDEX
I have a column containing two concatenated data separated by a '/', I want to get only what is before '/' that is equal to a column of another table, so I am trying to use SUBSTRING with CHARINDEX, but I think I'm doing something wrong, follow the code.
SELECT TOP 1 * FROM arquivo A, tabela_geral B (NOLOCK), campo_concatenado C (NOLOCK)
WHERE A.primeira_parte = SUBSTRING(C.concatenado, 1, CHARINDEX('/', C.concatenado) -1)
AND B.status = 0
AND B.campo = '13'
AND B.numero NOT IN (6, 78, 79, 80, 81, 82, 83, 91)
Solution 1:[1]
Did you tried this ?
SELECT TOP 1 * FROM arquivo A, tabela_geral B (NOLOCK), campo_concatenado C (NOLOCK)
WHERE A.primeira_parte = "%/"
AND B.status = 0
AND B.campo = '13'
AND B.numero NOT IN (6, 78, 79, 80, 81, 82, 83, 91)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
