Concatenate Message In RAISERROR

You can use %s as a string substitution parameter in 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);

Leave a Comment