# T-SQL and client compatibility

> Compare driver operations, procedure calls, type precision, collation and rollback with the application’s requirements.

---

LLMS index: [llms.txt](/llms.txt)

---

## Which client operation was tested? {#clients}

| Client or API | Observed result | What to check for an application |
| --- | --- | --- |
| FreeTDS 1.5.18 `tsql`, TDS 7.4 | On the matching Rocky x86-64 build, password login, logical database selection, table DDL, two-row DML, a procedure call and TLS 1.2 worked. | Run the actual result sets and parameter types through the driver used in production. |
| Microsoft JDBC 8.2.2.jre8 `SQLServerBulkCopy` | On a preceding integrated PG19 build with the same Babelfish extension tree, two integers reached an encrypted table. PG read 2 and 40. The bulk test used `databaseName=master;encrypt=false` on loopback. | Check server-side row counts and values. Re-test with the deployed JDBC version, TLS settings and real column types. |
| FreeTDS 1.3.17 `freebcp` | On the standalone PG19 port and upstream beta, the utility reported two rows copied. The server rejected the bulk packet and stored zero. | Reconcile counts on the target. Use the exercised JDBC bulk path or parameterized inserts after testing them with the application. |
| `sqlcmd`, SSMS, .NET SqlClient, ODBC and Python drivers | Upstream documents SQL Server clients. There is no complete application or driver-suite result for these tools on this Mimus build. | Check prepared RPCs, output parameters, result-set metadata, connection pooling and reset, cancellation and reconnect with the exact client version. |

## Procedures and batches {#procedures}

In FreeTDS `tsql` as `bbf_admin` in `master`, after the [two-row example](/docs/mssql/connect/#first-login), submit the definition and invocation as separate batches. The integer parameter `1` returned `amount = 40` and return status 0. This exercises a T-SQL call sent as a SQL batch. Driver RPC calls, output parameters and multiple results take additional client paths.

```sql
CREATE PROCEDURE dbo.mimus_lookup @id int AS
BEGIN
    SELECT amount FROM dbo.mimus_probe WHERE id = @id;
END;
GO
EXEC dbo.mimus_lookup @id = 1;
GO
```

For procedures using temporary objects, inventory each `@table` and `#temp`, including those in nested procedures. Compare success, error and rollback paths with the source application. Use a separate batch for each procedure definition and let the client consume `GO`. Drivers executing SQL strings generally need the caller to split batches.

The default escape hatches for index clustering and storage options are `ignore`. A migrated `PRIMARY KEY CLUSTERED` or filegroup clause can parse without reproducing SQL Server’s physical layout. Check the resulting indexes and query plans. Procedures that rely on equivalent locking or placement need a separate design. [Upstream T-SQL settings](https://github.com/babelfish-for-postgresql/babelfish_extensions/blob/a6e79da1b28c72e4801abbc9b58f946c10fcb6f9/contrib/babelfishpg_tsql/src/guc.c)

## Types, text comparison and views {#types}

| Case | Observed behavior | Migration decision |
| --- | --- | --- |
| Fractional time | On the earlier four-component tree, the nanosecond part of `CAST('2000-01-01T12:34:56.1234567' AS datetime2(7))` was `123457000`. SQL Server’s type can represent 100 ns. | If the seventh digit orders events or distinguishes keys, retain the source ticks in an integer or exact numeric column. |
| `ISNULL` in a persisted view | On an earlier integrated build, with a nullable `varchar(3)` column and a `varchar(6)` replacement, the `ISNULL` view column kept the first input’s type modifier. `COALESCE` had no length modifier. A concatenated TDS query returned `abcdef/abcdef` for the NULL row. SQL Server documents possible truncation to the first argument’s type. | Specify the required result width explicitly. Check the returned value **and** the metadata through the application driver. |
| Collations and trailing spaces | The default server collation is `sql_latin1_general_cp1_ci_as`. In a PG19 comparison, native `text` under `sys.bbf_unicode_cp1_ci_as` and `sys.bbf_unicode_cp1_cs_as` agreed with matching ICU controls. Case differed between CI and CS. Both distinguished a trailing space. T-SQL `varchar` equality ignored the trailing space. | Replay joins, unique keys and orderings with case, accents, composed characters and trailing spaces. Carry the intended type and collation into native queries. |
| Numeric, monetary, binary and identifier types | The extensions supply SQL Server types and conversions, including `money`, `uniqueidentifier`, `datetimeoffset` and `sql_variant`. The integer bulk-copy result covers none of their wire encodings. | Round-trip decimal scale, Unicode, raw bytes, offsets, NULLs and the base type of variant values through the intended import path. |
| `TOP … PERCENT` views | Four earlier PG19 TDS view cases returned 5, 7, 4 and 3 rows. They covered plain selection, unions and values. | Compare your view’s ordering and ties on real rows before relying on the selected subset. |

[SQL Server datetime2](https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetime2-transact-sql) · [SQL Server ISNULL](https://learn.microsoft.com/en-us/sql/t-sql/functions/isnull-transact-sql) · [Upstream Babelfish data types](https://github.com/babelfish-for-postgresql/babelfish_extensions/tree/a6e79da1b28c72e4801abbc9b58f946c10fcb6f9/contrib/babelfishpg_common/sql)

## Transactions and temporary objects {#transactions}

In the PG19 integrated heap tests, each object started with 7. An explicit transaction added 4 and rolled back. The batch-local `@table` retained both rows (sum 11). A local `#temp`, `SELECT INTO #temp` and a persistent table each returned 7. A new batch also ends a table variable’s scope. Code that needs data in subsequent batches should choose its object and connection lifetime accordingly. The default encrypted access method changes whether these objects can be created. [T-SQL temporary-object settings and storage](/docs/mssql/temporary-storage/)

In a PG19 three-protocol concurrency test at READ COMMITTED, a TDS update waited on a locked integer primary key. An in-place change committed by the lock holder yielded one updated row. A committed delete and reinsert with the same key yielded zero for the waiting TDS update, even though the replacement row existed. The result held on heap and `tde_heap`. Compare `@@ROWCOUNT` and retry logic under the SQL Server application’s actual isolation settings. The concurrency run had no SQL Server reference instance. [PostgreSQL transaction isolation](https://www.postgresql.org/docs/19/transaction-iso.html)

---

Backlinks:

- [SQL Server](/docs/mssql/)
- [Known limits and troubleshooting](/docs/mssql/status/)
