Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
How To Create Stored Procedures with Parameters in MS SQL Server?
Submitted by: AdministratorVery often, you need to create a stored procedure with one or more parameters. You only supply values to those parameters at the time of executing the stored procedure.
Stored procedures with parameters can be created with the following syntax:
CREATE PROCEDURE procedure_name
@parameter_1 datatype,
@parameter_2 datatype,
...
@parameter_n datatype
AS
statement_1;
statement_2;
...
statement_n;
GO
The following tutorial exercise shows you how to create a stored procedure with one parameter called @url:
USE GlobalGuideLineDatabase;
GO
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
Submitted by: Administrator
Stored procedures with parameters can be created with the following syntax:
CREATE PROCEDURE procedure_name
@parameter_1 datatype,
@parameter_2 datatype,
...
@parameter_n datatype
AS
statement_1;
statement_2;
...
statement_n;
GO
The following tutorial exercise shows you how to create a stored procedure with one parameter called @url:
USE GlobalGuideLineDatabase;
GO
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
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.