I have the following query:
exec sp_executesql N'SELECT * FROM table WHERE ( ( (
myfield = Id1 AND myOtherField = @Id2)))'
,N'@Id1 nvarchar(50),@Id2 bigint',@Id1=N'default
value',@Id2=1
This is obviously very trimmed down. Notice that @Id1 equals the value "default value", and the space corresponds with a line break in the text. This is the way it shows up in the SQL Profiler.
This query does not return a value (in a query window or in the app), but if I remove the line break, it does return one row ("default value" is actually a valid primary key. I am amazed, as I would think that the query text would get passed to the provider as a stream, or at least that it would not introduce line breaks.
Anyone else ever run into this? Is this a known problem?
Thanks for any insight,
Phil