1: In a user-defined function, use the RETURNS clause to specify the data type of the function’s return value
Example:
CREATE FUNCTION dbo.f_getdate(
@year int, --The year to be queried
@bz bit bz=0 Query working days, @bz=1 Query rest days, @bz IS NULL Query all dates
)RETURNS @re TABLE(id int identity(1,1),Date datetime,Weekday nvarchar(3))
,, ,
2: return is used to return specific values/value variables
create procedure InsertNewCategory @CategoryName varchar(50), @ParentID int as INSERT INTO BookCategory(CategoryName,ParentID) values (@CategoryName,@ParentID) return
The result is:
if @@error <>0
return -1 --failure
else
return 1 --success