Skip to content
Advertisement

Django change upgrade MSSQL database

I have a Django app that was running without any problem with SQL server 2008, I have an issue like this after I upgraded the MS SQL server 2008 into 2019. I didn’t change anything in the code but when I’m calling the DB, I face this error:

42000′, ‘[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot find either column “dbo” or the user-defined function or aggregate dbo.REGEXP_LIKE”, or the name is ambiguous.
(4121) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]
Statement(s) could not be prepared. (8180)

Advertisement

Answer

The issue was about Regex on Django and SQL server. SQL server doesn’t support Regex. So, You have to add an assembly to patch the SQL server. To do so, You need to have a Class library in .netframework to create a .dll file. Here is the code for the class library:

JavaScript

Then you need to configure your DB using this SQL script:

JavaScript

then your db would work with REGEX properly.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement