Collections:
Passing Expressions to Stored Procedure Parameters in SQL Server
Can You Pass Expressions to Stored Procedure Parameters in SQL Server Transact-SQL?
✍: FYIcenter.com
Can you pass expressions to stored procedure parameters? The answer is no.
When executing stored procedures, all input values must be entered as data literals, which can be specified within single quotes ('), or without them if they cause no confusion. The tutorial exercise below shows you how input values should be specified:
CREATE PROCEDURE area_of_circle @radius REAL AS BEGIN PRINT 'Radius = ' + STR(@radius,9,3); PRINT 'Area = ' + STR(3.14*@radius*@radius,9,3); END; GO -- Input value without quotes EXEC area_of_circle 1.5; GO Radius = 1.500 Area = 7.065 -- Input value with quotes EXEC area_of_circle '1.5'; GO Radius = 1.500 Area = 7.065 -- Expressions are not allowed EXEC area_of_circle 1.0+0.5; GO Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '+'.
⇒ Providing Default Values to Procedure Parameters in SQL Server
⇐ Passing Name-Value Pairs as Parameters in SQL Server
2016-12-28, 1593🔥, 0💬
Popular Posts:
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...
What Happens to Your Transactions When ERROR 1213 Occurred in MySQL? If your transaction receives th...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
How To Look at the Current SQL*Plus System Settings in Oracle? If you want to see the current values...