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
UsageAS
BEGIN
DECLARE @SQLStatement varchar(max)
SET @SQLStatement ='select * from Employee where EmployeeName = ' + '''' + @EmpName + ''''
EXEC (@SQLStatement)
END
[DynamicSQL_PassSingleVal] 'Bheem'
Click here to see how to Pass Multiple values as parameter dynamically
No comments:
Post a Comment