SQL Database Query

Hello all

I am using the SQL Database Plug-in to obtain some information. The problem is that when I use a SELECT * FROM table , all the data comes through properly. However, when I use a specific query, the information is not found, even though the same query works correctly when run directly on the SQL server.

Could you help me?

This is the query that is not working

SELECT *
FROM [Data].[dbo].[Datatest]
WHERE ‘cva.tex’ LIKE ‘%’ + REPLACE(BASEFILENAME, ‘*’, ‘’) + ‘%’

and on [Data].[dbo].[Datatest] exist the value cva*

What is BASEFILENAME?

BASEFILENAME is a field on the table that contain the name of the files and the value cva* is one of those values

Here is other sample this sample run correct on SQL but not on the plug in

The field BASEFILENAME contain the value 202343869117

DECLARE @FullFileName NVARCHAR(255)
SET @FullFileName = ‘202343869117_25072024_concat.txt’

SELECT*
FROM [Data].[dbo].[Datatest]
WHERE @FullFileName LIKE ‘%’ + LTRIM(RTRIM(BASEFILENAME)) + ‘%’

I believe the statement must be either a simple query or a call to a Stored procedure.

In addition, not all SQL functions are supported (it depends on a number of factors, including the driver you’re using). LTRIM() and RTRIM() seem to be supported supported, but I get an error message with REPLACE().

Do you receive an error message as well?

In my case it doesn’t give me any error, it just doesn’t bring me data, when in SQL it does exist

Perhaps someone else in our community with more SQL experience can help. Otherwise, you might want to contact our Support team to see if they can help you figure things out.