函数的创建及使用时的注意事项
函数的创建及使用时的注意事项 --以下是sql中函数的创建及使用方法 create function test(@Num varchar(20))--@Num 参数 returns varchar(50) --返回值类型 as begin declare @MSG varchar(20) if(@Num =1) ??? select @MSG ='正确' else ??? select @MSG ='错误' return @MSG end --调用函数 select dbo.test(2)—-这里的表名一定得加上dbo不加就报错
?
--创建返回table类型的函数 create function GetAllStudents() returns table as return (select * from student) --调用函数 select * from GetAllStudents()—-这里的表名可加可不加dbo (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |