Skip to main content
edited body
Source Link
Joel Coehoorn
  • 418.3k
  • 114
  • 581
  • 818

It sounds like you're wanting to see the parameters substituted directly in the query string "as it's done on the server". This is not possible, because the server _never substitutes the parameters into the string. That'snever substitutes the parameters into the string. That's the beauty of parameterized queries: data is data, code is code, and never that twain shall meet.

Given a simple query like this:

SELECT * FROM MyTable WHERE ID=@ID

Rather than running it like this:

SELECT * FROM MyTable WHERE ID=1234

You can think of it as if the database actually runs a procedure like this:

DECLARE @ID int
SET @ID = 1234
SELECT * FROM MyTable WHERE ID=@ID

It sounds like you're wanting to see the parameters substituted directly in the query string "as it's done on the server". This is not possible, because the server _never substitutes the parameters into the string. That's the beauty of parameterized queries: data is data, code is code, and never that twain shall meet.

Given a simple query like this:

SELECT * FROM MyTable WHERE ID=@ID

Rather than running it like this:

SELECT * FROM MyTable WHERE ID=1234

You can think of it as if the database actually runs a procedure like this:

DECLARE @ID int
SET @ID = 1234
SELECT * FROM MyTable WHERE ID=@ID

It sounds like you're wanting to see the parameters substituted directly in the query string "as it's done on the server". This is not possible, because the server never substitutes the parameters into the string. That's the beauty of parameterized queries: data is data, code is code, and never that twain shall meet.

Given a simple query like this:

SELECT * FROM MyTable WHERE ID=@ID

Rather than running it like this:

SELECT * FROM MyTable WHERE ID=1234

You can think of it as if the database actually runs a procedure like this:

DECLARE @ID int
SET @ID = 1234
SELECT * FROM MyTable WHERE ID=@ID
Source Link
Joel Coehoorn
  • 418.3k
  • 114
  • 581
  • 818

It sounds like you're wanting to see the parameters substituted directly in the query string "as it's done on the server". This is not possible, because the server _never substitutes the parameters into the string. That's the beauty of parameterized queries: data is data, code is code, and never that twain shall meet.

Given a simple query like this:

SELECT * FROM MyTable WHERE ID=@ID

Rather than running it like this:

SELECT * FROM MyTable WHERE ID=1234

You can think of it as if the database actually runs a procedure like this:

DECLARE @ID int
SET @ID = 1234
SELECT * FROM MyTable WHERE ID=@ID