IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_sys_getusercode]') AND type = 'FN')
DROP FUNCTION [dbo].[mps_sys_getusercode]
GO
create function [dbo].[mps_sys_getusercode](
@name varchar(50) ,
@objid int,
@objid2 int  
)
RETURNS nvarchar(MAX)  
AS
BEGIN
declare @t nvarchar(MAX) 
select top 1 @t=cd_text  from mps_extsqljs where cd_objid=@objid and cd_objid2=@objid2 and cd_name=@name  
set @t = isnull(@t,'') 
RETURN(@t) 
END