IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[up_myinfo_mobile]') AND type = 'P')
DROP PROCEDURE [dbo].[up_myinfo_mobile]
GO
create PROCEDURE [dbo].[up_myinfo_mobile]
@fldname nvarchar(100),
@fldvalue nvarchar(100),
@cmpid int,
@cuid int
AS
declare @str nvarchar(1000)
declare @error nvarchar(100)
BEGIN

if exists(select 1 from mps_employee where cu_mobile=@fldvalue)
begin
set @error=0
end
else
begin
set @str='update mps_employee set '+ convert(nvarchar(1000),@fldname)+'='''+@fldvalue+''''+' where cu_cmpid= '+convert(nvarchar(100),@cmpid)
+' and cu_id= '+convert(nvarchar(100),@cuid)
set @error=1
end
select @error as error
exec(@str)
END