Reputation: 2087
I am trying to create a query for a prototype but can't seem to get it to work. I have no idea. The first query was captured using Express Profiler. The second query is just a copy, and paste from the first query. The only difference is that in the second query I copied/pasted the param value directly from the row in the database. Why are these two queries returning different results?
I did change the queries before posting this, so ignore any minor mistakes I may have missed. I did this to remove client specific details.
exec sp_executesql N'SELECT DISTINCT COUNT(*)
FROM [Test_Import]
WHERE CONCAT(Name, '' -- '', City, '', '', State, '', '', Zip) =
@Info', N'@Info nvarchar(49)',
@Info=N'LLC -- Morganton, NC, 28655'
go
exec sp_executesql N'SELECT DISTINCT COUNT(*)
FROM [Test_Import]
WHERE CONCAT(Name, '' -- '', City, '', '', State, '', '', Zip) =
@Info', N'@Info nvarchar(49)',
@Info=N'LLC -- Morganton, NC, 28655'
go
Insert values
INSERT INTO [dbo].[Test_Import] ([Name], [City], [State], [Zip])
VALUES ('LLC', 'Morganton', 'NC', '28655')
Create table
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Test_Import]
(
[Name] [varchar](200) NULL,
[City] [varchar](200) NULL,
[State] [varchar](200) NULL,
[Zip] [varchar](200) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Upvotes: 0
Views: 533
Reputation: 159
check if there is any hidden characters beneath the parameter
you can do that by copy and paste this sql into Notepad++
From Notepad++ menu goto view-->show Symbol --> show all characters
This will help you figure out the difference
Upvotes: 1