CREATE PROCEDURE [REG_GetAccounts] @AccountId BIGINT = NULL, @UserId BIGINT = NULL AS SELECT AccountId, UserId, Symbol, CurrentBalance, CurrentBonusBalance, TotalPending, CreateDate, LastModifyDate, LastModifyOrigin, LastModifyOperatorId, WalletAddress FROM [Accounts] with (nolock) WHERE [Accounts].[AccountId] = ISNULL(@AccountId, [Accounts].[AccountId]) AND [Accounts].[UserId] = ISNULL(@UserId, [Accounts].[UserId]) RETURN 0