SQL Server 2022 Legacy Database with Laravel 12 Issue
Working on a Laravel project that uses SQLServer 2022 and a “legacy” database. I tried to use the kitloong/laravel-migrations-generator package so I could generate migrations for the whole database, but got continual errors like this:
[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Incorrect syntax near '('.
(Connection: sqlsrv, SQL: select idx.name as name, string_agg(col.name, ',')
within group (order by idxcol.key_ordinal) as columns,
It turns out that although my SQL Server is 2022, the compatibility for my legacy database must have been for a prior levell which caused the artisan migrate:generate command to fail.
Updating the compatibility level of the database made this command work:
"ALTER DATABASE scswebdata SET COMPATIBILITY_LEVEL = 160;"
Did not know that you could configure the compatibility level with SQL Server.