Collections:
Passing Expressions to Function Parameters in SQL Server
Can You Pass Expressions to Function Parameters in SQL Server Transact-SQL?
✍: FYIcenter.com
Can you pass expressions to stored procedure parameters? The answer is yes.
When executing functions, input values can be written as expressions. But the resulting value data type must match the parameter. The tutorial exercise below shows you how input values should be specified:
USE FyiCenterData; GO CREATE FUNCTION Area(@radius REAL) RETURNS REAL AS BEGIN RETURN 3.14*@radius*@radius; END; GO -- Input value data matches the parameter PRINT 'Area of a circle: '+STR(dbo.Area(1.5),9,3); GO Area of a circle: 7.065 -- Input value data does not match the parameter PRINT 'Area of a circle: '+STR(dbo.Area('1.5'),9,3); GO Msg 102, Level 15, State 1, Line 3 Incorrect syntax near 'Area'. -- Expressions are allowed PRINT 'Area of a circle: '+STR(dbo.Area(1.0+0.5),9,3); GO Area of a circle: 7.065
⇒ DEFAULT - Providing Default Values to Function Parameters in SQL Server
⇐ Passing Values to User Defined Function Parameters in SQL Server
2016-12-18, 1781🔥, 0💬
Popular Posts:
How To Create a Table Index in Oracle? If you have a table with a lots of rows, and you know that on...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
What Is ISAM in MySQL? ISAM (Indexed Sequential Access Method) was developed by IBM to store and ret...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...