这是解决方案。
CREATE FUNCTION GetAIntFromStoredProc(@parm Nvarchar(50)) RETURNS INTEGER
AS
BEGIN
DECLARE @id INTEGER
set @id= (select TOP(1) id From tbl where col=@parm)
RETURN @id
END
然后我们进行选择查询
Select col1, col2, col3,
GetAIntFromStoredProc(T.col1) As col4
From Tbl as T
Where col2=@parm