CREATE FUNCTION [dbo].[f_get_hosname]() RETURNS varchar(255) AS BEGIN DECLARE @hospital_name VARCHAR(255); select @hospital_name = hospital_name from xk_hos_info where sfby = 'Y' ; return @hospital_name END; GO