20
¿Cuál es la sintaxis correcta aquí?Concatenar mensaje en RAISERROR
If (@timestamp < (Select PromoStartTimestamp From @promo))
RAISERROR('Code not valid until ' + (Select PromoStartTimestamp From @promo)
,16
,1);
He intentado:
If (@timestamp < (Select PromoStartTimestamp From @promo))
RAISERROR(N'Code not valid until @starttimestamp'
,16
,1
,(Select PromoStartTimestamp From @promo));
respuesta de
Michael Fredrickson me da un error de Incorrect syntax near 'CAST'.
Me sale un error cuando intento 'Cast (@promostarttimestamp como varchar)' say ing 'Sintaxis incorrecta cerca de 'Cast'. Esperando Seleccionar o ('o cuando no' Cast' Obtengo 'No se puede especificar el tipo de datos de fecha y hora (parámetro 4) como un parámetro de sustitución. – Greg
+1 para'% s' pero no se pueden usar expresiones (CAST) en Parámetros RAISERROR. Tiene que ser isntead 'RAISERROR (Código N'no válido hasta% s ', 16, 1, @ PromoStartTimestampCastedToString));' –
D'oh! Gracias @RemusRusanu ... debería funcionar mejor ahora. –