1
I would like to make a query in a column and that the return is only the uppercase words that correspond to the searched criteria (user input), no matter if the criterion was typed in uppercase or lowercase.
CREATE PROCEDURE uspConsultaSobrenome
@Sobrenome nvarchar(MAX)
AS
BEGIN
SELECT
SobrenomeID,
Sobrenome
FROM
tbl_Sobrenomes
WHERE
Sobrenome LIKE @Sobrenome + N'%'
END
I did so and the answer is both lowercase and uppercase.
https://msdn.microsoft.com/pt-br/library/ms180055.aspx use the Function UPPER
– Motta
I would not like to convert, but rather that the query read only the words that are already capitalized in the column "Last name" and return these words and the others ignored.
– Daniel
Last name LIKE upper(@Last name + N'%') must resolve
– Motta
@Motta, not solved. Return also the "last names" in lower case in the column "Last names".
– Daniel
Surname LIKE upper(@Surname + N'%' and Surname = upper(Surname)
– Motta
@Motta, unfortunately not either. Keeps returning both words.
– Daniel
so I’m sorry I didn’t understand the problem.
– Motta
@Motta, on the line there are several words. I want you to refer to return the word that meets the criteria, as long as it is capitalized.
– Daniel
Show examples in the definition please.
– Motta
I put an example image @Motta
– Daniel
And in case your example is to return what ?
– Motta
the surname in capital letters. Example: ADAMI.
– Daniel
https://docs.microsoft.com/en-us/sql/t-sql/functions/charindex-transact-sql try using FUNCTION CHARINDEX , maybe combining with SUBSTR to get only the part that matters.
– Motta