[sql-server-2008] how to create and call scalar function in sql server 2008

I have created a Scalar Functions, it was created successfully, but when I call the function using select statement, it says invalid object, I altered the function, I got the message command completed successfully, but when I call the function, I gets same error. below is the function I am trying to call:

ALTER FUNCTION [dbo].[fn_HomePageSlider]
(
    @PortalID int,
    @ArticleID int
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
    DECLARE @HTML NVARCHAR(MAX)
    SET @HTML = '';
    Declare @Title varchar(1000)
    Select @Title= Title from CrossArticle_Article c where c.Id=@ArticleID
    Select @HTML = @HTML + '<div class="homeSlider">
                                <div class="text">'+ISNULL(c.Title,'')+'</div>
                            </div>'
    FROM CrossArticle_Article c INNER JOIN crossarticle_url U ON U.articleid=c.Id
    INNER JOIN FREETEXTTABLE(CrossArticle_Article,TITLE,@TITLE) as INDEX_TBL 
    ON INDEX_TBL.[KEY]=c.Id
    WHERE INDEX_TBL.RANK >= 75 AND 
    c.Id<>@ArticleID AND
    c.PortalId=@PortalID
    GROUP BY c.Title,U.url,INDEX_TBL.RANK
    ORDER BY INDEX_TBL.RANK DESC

    RETURN @HTML;
END

And below is the way I am calling the function:

SELECT * FROM dbo.fn_HomePageSlider(9, 3025)

Can anyone tell me what's wrong with the above function, as I get the message command completed successfully.

This question is related to sql-server-2008 function call scalar

The answer is


Try

SELECT dbo.function (parameters)

Or you can simply use PRINT command instead of SELECT command. Try this,

PRINT dbo.fn_HomePageSlider(9, 3025)

Examples related to sql-server-2008

Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object How to Use Multiple Columns in Partition By And Ensure No Duplicate Row is Returned SQL Server : How to test if a string has only digit characters Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query Get last 30 day records from today date in SQL Server How to subtract 30 days from the current date using SQL Server Calculate time difference in minutes in SQL Server SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904) SQL Server Service not available in service list after installation of SQL Server Management Studio How to delete large data of table in SQL without log?

Examples related to function

$http.get(...).success is not a function Function to calculate R2 (R-squared) in R How to Call a Function inside a Render in React/Jsx How does Python return multiple values from a function? Default optional parameter in Swift function How to have multiple conditions for one if statement in python Uncaught TypeError: .indexOf is not a function Proper use of const for defining functions in JavaScript Run php function on button click includes() not working in all browsers

Examples related to call

ReactJS - Call One Component Method From Another Component Call a Class From another class What does it mean to "call" a function in Python? How to make method call another one in classes? How to call a mysql stored procedure, with arguments, from command line? Submit form on pressing Enter with AngularJS Running bash script from within python javascript: get a function's variable's value within another function Passing variables, creating instances, self, The mechanics and usage of classes: need explanation Android Call an method from another class

Examples related to scalar

How to multiply all integers inside list TypeError: only length-1 arrays can be converted to Python scalars while trying to exponentially fit data Constructing pandas DataFrame from values in variables gives "ValueError: If using all scalar values, you must pass an index" python: how to identify if a variable is an array or a scalar how to create and call scalar function in sql server 2008 Python RuntimeWarning: overflow encountered in long scalars PHP - cannot use a scalar as an array warning PHP Constants Containing Arrays?