Home  >  Article  >  php教程  >  A brief discussion on the difference between return and returns in sql

A brief discussion on the difference between return and returns in sql

高洛峰
高洛峰Original
2016-12-14 13:00:422731browse

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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn