int
変数を raiserrorに表示しようとしていますが@MaxAmount
、@MinAmount
Raiserror('Total Amount should be less than %s and Greater than %s',16,1,@MaxAmount,@MinAmount)
しかし、私はエラーが発生しています:
スカラー変数「@MaxAmount」を宣言する必要があります。
int
変数を raiserrorに表示しようとしていますが@MaxAmount
、@MinAmount
Raiserror('Total Amount should be less than %s and Greater than %s',16,1,@MaxAmount,@MinAmount)
しかし、私はエラーが発生しています:
スカラー変数「@MaxAmount」を宣言する必要があります。
%s
が使用されvarchar
、変数がタイプであるint
ため、正しいフォーマット指定子を使用する必要があります。つまり、%d
DECLARE @MaxAmount int = 16;
DECLARE @minAmount int = 1;
Raiserror('Total Amount should be less than %d and Greater than %d',@MaxAmount,@MinAmount)
詳細については、 RAISEERRORを確認してください。
整数には %I を使用する必要があり、前述のように、使用前に変数を宣言します。
declare @MaxAmount int, @MinAmount int
select @MaxAmount = 50, @MinAmount = 5
Raiserror('Total Amount should be less than %i and Greater than %i',16,1,@MaxAmount,@MinAmount)
私はあなたがこの方法で試していると思います:
DECLARE @MaxAmount int = 16;
DECLARE @MinAmount int = 1;
Raiserror('Total Amount should be less than %d and Greater than %d',@MaxAmount,@MinAmount)
RAISERROR の詳細については、こちらをご覧ください。