CREATE procedure [dbo].[up_insert_agentaccount] @Account nvarchar(16), @Password nvarchar(16) as BEGIN set nocount on BEGIN TRAN if NOT EXISTS (select Account from dbo.AgentAccount with (nolock) where [Account] = @Account) begin insert into dbo.AgentAccount ( [Account], [Password] ) values ( @Account, @Password ); end if(@@error <> 0 ) BEGIN ROLLBACK TRAN return END COMMIT TRAN END