Skip to content
Advertisement

inserting a variable into openquery

I’m trying to insert a variable into the openquery expression, but unfortunately I get an error, does anyone know where I got this error?

Arithmetic overflow error when converting expression data to int data type.

Advertisement

Answer

OPENQUERY requires a literal string, you can’t put variables into it. As such you’ll need to create a dynamic statement and inject the value into the query safely:

Though, I must admit, I don’t see much point in this as it’s simply going to return the input parameter if the row(s) exist.

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