# SQL error 145 querying a sqlexpress database

**URL:** <https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556>\
**Category:** Ignition\
**Created:** [December 30, 2021, 11:17pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556 "2021-12-30T23:17:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 30, 2021, 11:17pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/1 "2021-12-30T23:17:18Z")

</div>

When ever I query the database and try to expand a entry in the database I get a sql query error 145. SQLunknown SQL type -145. The database shows a valid connection. Not sure what to do to solve this.

Database is a sqlexpress database

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 30, 2021, 11:50pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/2 "2021-12-30T23:50:18Z")

</div>

Show your SQL query. Tell us the version numbers of everything involved, including the JDBC driver. Show a screen shot of the data before and after you try to expand it.

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 12:14am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/3 "2021-12-31T00:14:17Z")

</div>

Just trying to expand it when opens I get the error

 ![image001.png](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/2/12d0f7b003a5856b23af6235de4dad9875120c2c.png)

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 12:16am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/4 "2021-12-31T00:16:45Z")

</div>

Just trying to browser the table

![image001.png](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/669d4689b3de15144558e411970b8b651431d0fa.png)

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 12:18am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/5 "2021-12-31T00:18:23Z")

</div>

![image001.png](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/5/e535ed83711bf822bd03cb3940fd05c21ecc556d.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 31, 2021, 12:20am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/6 "2021-12-31T00:20:01Z")

</div>

Very likely there’s a column type in that table that isn’t supported by your JDBC driver.

{ For text, like error details or code, don’t use screenshots. Paste the raw text, highlight what you pasted, then click the “preformatted text” button. This one: \</\>. }

Try using SQL Server Management Studio to generate that table’s “create script” and paste it here.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 31, 2021, 12:27am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/7 "2021-12-31T00:27:59Z")

</div>

This topic might help, too:

> [@SQL Server Connection Faulted](https://forum.inductiveautomation.com/t/sql-server-connection-faulted/46393/9):
>
> You might need to downgrade. The case I encountered was a SQL Server 2008, which isn’t supported past driver 6.2. See this compatibility chart: I think with the correct driver, I didn’t need the extra connection properties, just the java.security changes. YMMV, of course.

But note that the oldest JDBC drivers don't work in java 11, IIRC.

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 1:01am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/8 "2021-12-31T01:01:59Z")

</div>

Create script

USE [Department505]

GO

/\*\*\*\*\*\* Object: Table [dbo].[AssemblyLineTransactions] Script Date: 12/30/2021 7:00:03 PM \*\*\*\*\*\*/

SET ANSI\_NULLS ON

GO

SET QUOTED\_IDENTIFIER ON

GO

CREATE TABLE [dbo].[AssemblyLineTransactions](

[ItemGuid] [uniqueidentifier] NOT NULL,

[ROWID] [int] IDENTITY(1,1) NOT NULL,

[StationId] [int] NOT NULL,

[DateEntered] [datetime] NOT NULL,

[TransactionTypeId] [int] NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[AssemblyLineTransactions] ADD CONSTRAINT [DF\_Department505AssemblyLineTransactions\_ItemGuid] DEFAULT (newid()) FOR [ItemGuid]

GO

ALTER TABLE [dbo].[AssemblyLineTransactions] ADD CONSTRAINT [DF\_Department505AssemblyLineTransactions\_DateEntered] DEFAULT (getdate()) FOR [DateEntered]

GO

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 31, 2021, 1:43am UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/9 "2021-12-31T01:43:15Z")

</div>

A bit of googling suggests it might be the `uniqueidentifier` column type. Check your JDBC driver against the compatibility matrix in the link I posted.

{ Please edit your comment to mark pasted SQL as preformatted text. }

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/10 "2021-12-31T13:14:05Z")

</div>

I don’t see anything on the Microsoft site that discusses data type compatibility and the driver, maybe I am looking in the wrong place. I see database compatibility table.

---

<div class="post-metadata">

**Author:** ![Scott\_Kay](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Scott\_Kay](https://forum.inductiveautomation.com/u/Scott_Kay)\
**Post date:** [December 31, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/11 "2021-12-31T13:14:56Z")

</div>

Here is the link I am looking at [Support matrix - JDBC Driver for SQL Server | Microsoft Docs](https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver15)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 31, 2021, 2:09pm UTC](https://forum.inductiveautomation.com/t/sql-error-145-querying-a-sqlexpress-database/54556/12 "2021-12-31T14:09:03Z")

</div>

Yes, that’s what I’m talking about. I want you to verify that your install of Ignition is using the latest possible JDBC driver for the database version you are connecting to. If it still doesn’t work after that, you will have to experiment with your tables, SELECTing column by column, until you find the one Java doesn’t accept. Omit those columns from future SELECT operations, or change your tables to not use them.

Or change your database to one that plays better with Java. I’d switch to PostgreSQL, fwiw.
