Answers

Question and Answer:

  Home  MS SQL Server

⟩ How To Provide Values to Stored Procedure Parameters in MS SQL Server?

If a stored procedure is created with parameters, you need pass values to those parameters when calling the stored procedure with one of two formats listed below:

-- Passing values only

EXEC procedure_name value_1, value_2, ... value_n;

-- Passing name-value pairs

EXEC procedure_name

@parameter_1 = value_1,

@parameter_2 = value_2,

...

@parameter_n = value_n;

The tutorial exercise below shows 2 ways to pass values to stored procedure parameters:

DROP PROCEDURE Hello;

GO

CREATE PROCEDURE Hello

@url nvarchar(40)

AS

PRINT 'Welcome to ' + @url;

GO

EXEC Hello 'rendc.org';

GO

Welcome to rendc.org

EXEC Hello @url='rendc.org';

GO

Welcome to rendc.org

 129 views

More Questions for you: