2 回答
TA贡献1830条经验 获得超3个赞
如果只是单纯的把两个字段拼接起来没必要写自定义函数,查询语句就可以实现
select FirstName,LastName,FirstName+LastName FullName from EMPLOYEE
FullName是合并后的字段
TA贡献1804条经验 获得超3个赞
drop FUNCTION [dbo].[jzf_Get_IDNO]
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
create FUNCTION [dbo].[jzf_Get_IDNO]
(
-- Add the parameters for the function here
@ApartID nvarchar(40)
)
RETURNS nvarchar(40)
AS
BEGIN
-- Declare the return variable here
DECLARE @str nvarchar(40)
set @str=N'未查到'
-- Add the T-SQL statements to compute the return value here
SELECT @str=Isnull(IDNO,N'未定义') from mytable where objectid=@ApartID
-- Return the result of the function
RETURN @str
END
---------------------结果显示在,上述函数是标量值函数:
添加回答
举报