Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Like Statement With Parameters

$
0
0
I have a table :Person(Id bigint , FirstName nvarchar(50) , LastName nvarchar(50),Address nvarchar(100))and I have a sp for search data in "Person" table:CREATE PROCEDURE SelectPerson @First nvarchar(50) = NULL, @Last nvarchar(50) = NULL, @Address nvarchar(100) = NULLAS BEGIN SELECT * FROM Person WHERE ([FirstName] LIKE N'%' + @First +'%' OR @First IS NULL) AND ([LastName] LIKE N'%' + @Last +'%' OR @Last IS NULL) AND ([Address ] LIKE N'%' + @Address +'%' OR @Address IS NULL) ENDGOand there exists 500 record in Person.I execute SelectPerson by this code:"DECLARE @return_value intEXEC @return_value = [dbo].[SelectPerson ] @First = 'ام', @Last = NULL, @Address= NULLSELECT 'Return Value' = @return_valueGO"but result don't has any rows.why?

Viewing all articles
Browse latest Browse all 3145

Trending Articles