Du kan använda %s
som en strängersättningsparameter i 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);