Sqlserver
 SQL >> Base de données >  >> RDS >> Sqlserver

Concaténer un message dans RAISERROR

Vous pouvez utiliser %s comme paramètre de substitution de chaîne dans RAISERROR.

DECLARE @PromoStartTimestamp DATETIME; DECLARE @PromoStartTimestampString VARCHAR(50); SELECT @PromoStartTimestamp = PromoStartTimestamp FROM @promo; SELECT @PromoStartTimestampString = CAST(@PromoStartTimestamp AS VARCHAR); IF (@timestamp < @PromoStartTimestamp) RAISERROR(N'Code not valid until %s', 16, 1, @PromoStartTimestampString);