Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call scalar function in sql server 2008

Tags:

sql

sql-server

People also ask

What is scalar value function in SQL Server?

A Scalar-valued function in SQL Server 2012 is used to return a single value of any T-SQL data type. A CREATE FUNCTION statement is used to create a Scalar-valued function. The name of the function should not be more than 128 characters.

What is scalar value function?

Definition: A scalar valued function is a function that takes one or more values but returns a single value. f(x,y,z) = x2+2yz5 is an example of a scalar valued function. A n-variable scalar valued function acts as a map from the space Rn to the real number line. That is, f:Rn->R.


Your syntax is for table valued function which return a resultset and can be queried like a table. For scalar function do

 select  dbo.fun_functional_score('01091400003') as [er]

You have a scalar valued function as opposed to a table valued function. The from clause is used for tables. Just query the value directly in the column list.

select dbo.fun_functional_score('01091400003')

For some reason I was not able to use my scalar function until I referenced it using brackets, like so:

select [dbo].[fun_functional_score]('01091400003')

For Scalar Function Syntax is

Select dbo.Function_Name(parameter_name)

Select dbo.Department_Employee_Count('HR')