<> inline table-valued functions

create function Function name (@ variable as type )
returns table
Result set [select Query statement ]

select Listing from Function name ( Pass in value )

<> Example Programming a custom function , Receive a parameter course number , Add one to the grade of each student in the course (1~5) Random fraction of .
create function addgrade1(@cno3 char(3)) -- Define function body returns table -- The return value is a table surface
as return select sno,cno,grade+(select left( datepart(ms, getdate()),1)/2+1)as
fraction from t_score go select * from addgrade1('C01')
–select left( datepart(ms, getdate()),1)/2+1
Because it can't be used in custom functions rand
Then define a random number 1>> Gets the millisecond of the current time >> Take the first bit of the second millisecond >> Divide this number by 2 again +1 We can get the range value we want

<> Multi statement table valued function

©2019-2020 Toolsou All rights reserved,
Send love - A little romance for programmers VHDL—— Design of frequency divider Python Implementation of Hanoi Tower code It's over , Starting salary 30khtml+css+js Make a simple website home page QQ Login interface implementation Hill sorting of sorting algorithm ——c++ realization 【 Wechat applet learning 】 Netease music cloud code page implementation details Resume the 13th session python Blue Bridge Cup 2022 Solution to the 13th Blue Bridge Cup ( whole )