set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go create PROCEDURE [dbo].[STPIsAccountExist] @Title nvarchar(1000), @Code int=0 AS if @Code <> 0 if exists(SELECT AccountSysCode FROM CodeMNGDWNTbl WHERE (Title = @Title) AND (AccountSysCode <> @Code)) return 1 else return 0 else if exists(SELECT AccountSysCode FROM CodeMNGDWNTbl WHERE (Title = @Title)) return 1 else return 0