FireDAC truncates string literals containing ! characters (Delphi 10.4 + SQL Server 2017) - sql-server

There is some kind of pre-processment of the SQL text on FireDAC queries that truncates their string literals containing ! characters.
It's very easy to replicate:
Place a TFDConnection, a TFDQuery connected to the connection, a TDatasource connected to the query and a TDBEdit connected to the datasource.
After setting my server configuration on the TFDConnection, if I try this SQL on the TFDQuery : Select 'Hel!o World' as column, I would only see He on the TDBEdit instead of Hel!o World.
It's a problem of FireDAC because the same query runs fine directly on SQL Server Management Studio.
Is there a way to fix o disable this pre-processment of FireDAC ?.
It's Delphi 10.4 and SQL Server 2017 accessed by SQL Server Native Client (I have also tried the same query on Delphi 10.3 and returns the same error).
Thank you.

Related

Unreadable value returned in VBA/ADO from SQL Server 2019

To monitor SQL Server jobs in a VBA app, I run the sp_get_composite_job_info stored procedure from the msdb database using ADO. I check the current_execution_step field once I have the results in a ADODB.Recordset. This has worked fine with SQL Server 2012 for years.
We just migrated to SQL Server 2019 and now the same code which still works on SQL Server 2012 is returning an unreadable value for the current_execution_step field.
Instead of "4 (Step Name)", I get a bunch of rectangles and squares.
If I run the same call to sp_get_composite_job_info in SSMS, I can read the current_execution_step field just fine on both servers. It's only when I try to read that field in VBA/ADO that it's gibberish.
What's worse, I can read other fields from that same recordset just fine. It's only this one field (which just happens to be the only field I need to read) that is unreadable.
The driver I'm using in VBA is ODBC Driver 17 for SQL Server. But again, I use the same driver for both servers, and only 2019 has this issue.
What could be causing this?
The SQL Server 2012 version of sp_get_composite_job_info (undocumented as #RBarryYoung mentioned) returns current_execution_step as nvarchar(128) whereas SQL Server 2019 returns nvarchar(MAX).
ADO is unaware of SQL Server datatypes introduced after SQL Server 2000. Try installing the latest MSOLEDBSQL OLE DB driver (ADO is natively OLE DB) and specifying the DataTypeCompatibility=80 in the connection string.
Fortunately, the answer was as simple as going back to OLE and switching the Provider to SQLNCLI11 instead of SQLOLEDB. Since SQLNCLI11 is omnipresent, I don't have to hunt down all of the machines that might use these apps and install MSOLEDBSQL on them.

SQL Linked Server to UTF-8 database

I am trying to create a linked server from SQL Server 2008 R2 to an SAP IQ database, which has the UTF-8 Charset.
I am unable to get the correct characterset viewable on queries using this linked server.
I have tried everything, using native OLE DB provider of SAP IQ, using ODBC connectivity, playing with different connection strings, but my major concern is that it's impossible because SQL Server does not support UTF-8.
Correct characters when viewing in Interactive SQL:
Messed up characters in SQL Management Studio:
Any thoughts?
Finally solved it, after a few hours of debugging. :)
You have to use an ODBC connection, with the CharSet parameter set to 'windows-1252'. Then it works perfectly.

Connection is busy with results for another hstmt in delphi

i have developed a application in Delphi using Paradox and bde , now am migrating it into sql server 2008,
i have a lot of table and query components in every form, so am just create user DNS in ODBC manager with 'Sql Server - Driver' , and configure with BDE(connect sql server via BDE),
The problem is , while am working in some form, the error raised like
Connection is busy with results for another hstmt
Am tried with Sql native clinet , but i gives lot of troubles for me, so am using sql-server driver,
please any one help me to fix this problem, or give a steps to migrate paradox to sql server wihtout using 3rd party componets and ado,,,,
Try to set MARS_Connection=yes for your DSN.
SQL Server Driver has few issues when it works with SQL Server 2008. So, consider to use SQL Native Client 10.

Linked connection between MS SQL SERVER and Sybase ,Unicode problem

I added linked server on MS SQL SERVER 2008 with Sybase ASE 12.5 databases,
everything works fine, but i've got problem with unicode strings.
from MS SQL when i'am running
"SELECT * FROM OPENQUERY ( SYTEST ,'SELECT Name FROM PRODUCT')"
and the result set contains wrong characters
a?›a??a??a? a?”
a??a??a?¬a??a? a??
Name column in Sybase is of nvarchar type , names are written in unicode.
Problem occurs only when ms sql server is running on windows server operating system,
There is no problem on ms sql-servers running on Windows 7 and XP, where I got correct result.
try to use N#parameter when making query
If it works on 2 separate installs, you compare and check the linked server settings using sp_serveroption, especially collation compatible and collation name
If these are the same, check any DSN and Sybase driver settings in the OS
There is a case like this in my company
I've created a linked server from SQL Server 2014 to the IBM AS/400 (i series) and faced with the same problem.
I'm not sure about the different between 2014 and 2008 handle the unicode chars but I think it not much, if any.
How to
1. login to the SQL studio
2. right click the linked server then select "properties"
3. select "Server options" in left pane
4. set "Use remote collation" to "True"
5. in "Collation name", choose your unicode (here is the basic list - https://technet.microsoft.com/en-us/library/ms180175%28v=sql.105%29.aspx"
My problems solved this way! (I played a lot with connection strings with no desired results)

SQL Server 2008 USE database with [] Delphi ADO

In SQL server 2008 Management studio I can do this
Use [C:\test\somedb...]
When I use Delphi 2009 with the same command, using ADO, the [] seems to be interpreted as a parameter and the command fails with parameter improperly defined error. There is no parameter - I just need to use the [] because of the \ in the file name. Double quotes don't work either in Delphi / ADO or Management Studio.
Thanks in advance...
With ADO, you don't typically USE in the SQL. You specify the database and the other information (driver, etc.) in the ConnectionString. It works in SSMS because that's not using ADO; SSMS uses the SQL Server client directly (which has different requirements than ADO).
You can find connection string information for your specific SQL Server version here.

Resources