Reputation: 45
I have the following query, can you please suggest me what is wrong with this, its never entering inside the IF
block, even though data is present in a table.
DECLARE @AccountNumber NVARCHAR(50) ='54654654'
IF Exists( Select TOP 1 1 FROM [dbo].[CheckRecords] where DetailRecord like '% ' + @AccountNumber +' %')
BEGIN
Print 'Hello' + @AccountNumber
END
Upvotes: 0
Views: 310
Reputation: 44
DECLARE @AccountNumber NVARCHAR(50) ='54654654'
IF Exists( Select TOP 1 1 FROM [dbo].[CheckRecords]
where DetailRecord like '%' + @AccountNumber +'%')
BEGIN
Print 'Hello ' + @AccountNumber
END
try this it will work. it was not working because of extra space.
Upvotes: 1