SQL Server: Pass single value parameter dynamically

This is just an example to pass a single parameter dynamically.
CREATE PROC [dbo].[DynamicSQL_PassSingleVal](@EmpName varchar(500))
AS
BEGIN

DECLARE @SQLStatement varchar(max)
SET @SQLStatement ='select * from Employee where EmployeeName = ' + '''' + @EmpName + ''''

EXEC (@SQLStatement)

END

Usage
[DynamicSQL_PassSingleVal] 'Bheem'
Click here to see how to Pass Multiple values as parameter dynamically

No comments:

Post a Comment