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
---------------------結果顯示在,上述函數是標量值函數:
添加回答
舉報