Collections:
Passing Values to Stored Procedure Parameters in SQL Server
How To Provide Values to Stored Procedure Parameters in SQL Server Transact-SQL?
✍: FYIcenter.com
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 'dba.fyicenter.com'; GO Welcome to dba.fyicenter.com EXEC Hello @url='dev.fyicenter.com'; GO Welcome to dev.fyicenter.com
Â
2016-12-28, 1552👍, 0💬
Popular Posts:
How To Create a View on an Existing Table in SQL Server? If you want to a view on an existing table,...
How To Get a List of All Tables with "sys.tables" View in SQL Server? If you want to see the table y...
How AdventureWorksLT tables are related in SQL Server? There are 12 user tables defined in Adventure...
How To End a Stored Procedure Properly in SQL Server Transact-SQL? Where the end of the "CREATE PROC...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...