# Cannot use QueryAsset with Microsoft SQL Server (MSSQL)

**URL:** <https://discourse.greatexpectations.io/t/cannot-use-queryasset-with-microsoft-sql-server-mssql/1379>\
**Category:** GX Core Support\
**Created:** [September 11, 2023, 1:41pm UTC](https://discourse.greatexpectations.io/t/cannot-use-queryasset-with-microsoft-sql-server-mssql/1379 "2023-09-11T13:41:19Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![oneextrafact](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@oneextrafact](https://discourse.greatexpectations.io/u/oneextrafact)\
**Post date:** [September 12, 2023, 5:48pm UTC](https://discourse.greatexpectations.io/t/cannot-use-queryasset-with-microsoft-sql-server-mssql/1379/4 "2023-09-12T17:48:18Z")

</div>

@HaebichanGX, for what it’s worth the problem is in sqlalchemy\_batch\_data. I replaced the code for temp table gen with this:

```
    elif dialect == GXSqlDialect.MSSQL:
        # Insert "into #{temp_table_name}" in the custom sql query right before the "from" clause
        # Split is case-sensitive so detect case.
        # Note: transforming query to uppercase/lowercase has unintended consequences (i.e.,
        # changing column names), so this is not an option!
        # noinspection PyUnresolvedReferences
        if isinstance(query, sa.dialects.mssql.base.MSSQLCompiler):
            query = query.string # extracting string from MSSQLCompiler object

        querymod = query.split("*", maxsplit=1)
        stmt = f"{querymod[0]} * into {{temp_table_name}} {querymod[1]}".format(
            temp_table_name=temp_table_name
        )

```

I don’t think that’ll be the permanent fix, but I can run expectations with it in place

---

_[View the full topic](https://discourse.greatexpectations.io/t/cannot-use-queryasset-with-microsoft-sql-server-mssql/1379)._
