Collections:
Passing Name-Value Pairs as Parameters in SQL Server
What Are the Advantages of Passing Name-Value Pairs as Parameters in SQL Server Transact-SQL?
✍: FYIcenter.com
When calling a stored procedure defined with parameters, you can pass values to those parameters in two ways:
The advantages of passing name-value pairs to stored procedure parameters are:
The tutorial exercise shows you some good examples of passing name-value pairs as parameters:
CREATE PROCEDURE diff_in_days
@start_date DATETIME,
@end_date DATETIME
AS BEGIN
PRINT CONVERT(VARCHAR(20),@end_date,107)
+ ' - '
+ CONVERT(VARCHAR(20),@start_date,107)
+ ' = '
+ STR(DATEDIFF(DAY, @start_date, @end_date));
END;
GO
EXEC diff_in_days
'01-Jan-2007',
'19-May-2007';
GO
May 19, 2007 - Jan 01, 2007 = 138
EXEC diff_in_days
@start_date='01-Jan-2007',
@end_date='19-May-2007';
GO
May 19, 2007 - Jan 01, 2007 = 138
-- Name-value pairs can be given in any order
EXEC diff_in_days
@end_date='19-May-2007',
@start_date='01-Jan-2007';
GO
May 19, 2007 - Jan 01, 2007 = 138
⇒ Passing Expressions to Stored Procedure Parameters in SQL Server
⇐ Passing Values to Stored Procedure Parameters in SQL Server
2016-12-28, 2388🔥, 0💬
Popular Posts:
How To Verify Your PHP Installation in MySQL? PHP provides two execution interfaces: Command Line In...
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How To Query Tables and Loop through the Returning Rows in MySQL? The best way to query tables and l...
What Happens If the Imported Table Already Exists in Oracle? If the import process tries to import a...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...