Skip to content
Advertisement

SQL Argument data type int is invalid for argument 1 of charindex function

I’m trying to convert MySQL query to MsSql query but I’m having trouble. Here is my query:

MySQL

JavaScript

SQL I’ve tried

JavaScript

The errors I’m getting are:

JavaScript

For reference. http://sqlfiddle.com/#!3/4ed19/3

does anyone have any ideas? Thanks in advance!

Advertisement

Answer

Use this query. I just changed categories.id to CAST(categories.id AS VARCHAR). Because the id is integer in categories table.

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