|
INTERVIEW QUESTIONS
DATABASE
MS SQL SERVER
DETAILS
Question: How To Provide Values to Stored Procedure Parameters in MS SQL Server?
Answer: 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 'globalguideline.com'; GO Welcome to globalguideline.com
EXEC Hello @url='globalguideline.com'; GO Welcome to globalguideline.com
|
|
|
Category |
MS SQL Server Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9507 users |
Added on |
9/24/2014 |
Views |
70499 |
Rate it! |
|
|
Question:
How To Provide Values to Stored Procedure Parameters in MS SQL Server?
Answer:
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 'globalguideline.com'; GO Welcome to globalguideline.com
EXEC Hello @url='globalguideline.com'; GO Welcome to globalguideline.com Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How To Create Stored Procedures with Parameters in MS SQL Server?
|
View Answer
|
|
How To Modify an Existing Stored Procedure in MS SQL Server?
|
View Answer
|
|
How To Get the Definition of a Stored Procedure Back?
|
View Answer
|
|
How To Generate CREATE PROCEDURE Script on an Existing Stored Procedure?
|
View Answer
|
|
How To End a Stored Procedure Properly in MS SQL Server?
|
View Answer
|
|
How To Create a Stored Procedure with a Statement Block in MS SQL Server?
|
View Answer
|
|
How To Drop an Existing Stored Procedure in MS SQL Server?
|
View Answer
|
|
How To List All Stored Procedures in the Current Database using MS SQL Server?
|
View Answer
|
|
How To Execute a Stored Procedure in MS SQL Server?
|
View Answer
|
|
How To Create a Simple Stored Procedure in MS SQL Server?
|
View Answer
|
|
How To Create an Index on a View?
|
View Answer
|
|
How To Bind a View to the Schema of the Underlying Tables?
|
View Answer
|
|
How Column Data Types Are Determined in a View?
|
View Answer
|
|
How To Assign New Column Names in a View?
|
View Answer
|
|
Can We Delete Data from a View?
|
View Answer
|
|
Can We Update Data in a View?
|
View Answer
|
|
Can We Insert Data into a View?
|
View Answer
|
|
How To Modify the Underlying Query of an Existing View?
|
View Answer
|
|
Can You Use ORDER BY When Defining a View?
|
View Answer
|
|
What Happens If You Delete a Table That Is Used by a View?
|
View Answer
|