I have table in this records are 1 to 20 i want to perform searching with for example id , name , city , salary
i please tell me how to create stored procedure of that
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shubham KumarRank #621 · 3.8K reputationPosted Feb 11, 2016, 8:14 PM EST
@Id VARCHAR(50),
@Name VARCHAR(50)
AS
BEGIN
DECLARE @SqlQuery varchar(max), @Condition VARCHAR(max);
IF(@Id<>'')
BEGIN
SET @Condition='id='+@id;
END
ELSE IF(@Id<>'' AND @Name<>'')
BEGIN
SET @Condition='id='+@id +' and name='''+@name+'''';
END
SET @SqlQuery='select * from yourtable where'+ @Condition
END
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 12, 2016, 12:07 AM EST
(
@ID INT,
@NAME VARCHAR(50),
@GENDER VARCHAR(50),
@SALARY VARCHAR(50),
@COUNTRY VARCHAR(50)
)
Insert Value into Table
Then Execute Procedure
Alter PROCEDURE Employee_proc
(
@ID INT,
@NAME VARCHAR(50),
@GENDER VARCHAR(50),
@SALARY VARCHAR(50),
@COUNTRY VARCHAR(50),
@Opt varchar(2)
)
AS
BEGIN
IF(@Opt='S')
BEGIN
SELECT NAME from Employee WHERE NAME like @NAME + '%'
END
END
Employee_proc 0,'A','','','','S'