set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[EditListContacts] ( @ID int, @Address nvarchar(max), @Comment nvarchar(max), @Name nvarchar(max), @SysCode int, @TelNo nvarchar(50), @TelTypeId int, @Private bit ) AS declare @OwnerUserID int; select @OwnerUserID=(case when @private=1 then dbo.[FunUserId]() else 0 end) UPDATE TelBook SET Name = @name, Address = @Address, Comment = @Comment, OwnerUserID =@OwnerUserID WHERE (ID = @ID) UPDATE TelNumbers SET TelNo = @TelNo, TelNoType = @TelTypeId WHERE (SysCode = @syscode)