Given a table MyTable with a column MyCol defined as NVARCHAR(Max), the first SELECT returns one row in SSMS as expected while the second select returns no rows.
DECLARE @code NVarChar='ABC'
SELECT * FROM MyTable q WHERE MyCol = 'ABC'
SELECT * FROM MyTable q WHERE MyCol = @code
using ADO.Net to populate the parameter @code and execute the query also returns one row, as expected.
Why does the second SELECT return no rows when executed in SSMS?
SELECT @code;
Also please read sqlblog.com/blogs/aaron_bertrand/archive/2009/10/09/…