我在这里做错了什么?
Declare @starttimestamp datetime = getdate();
RAISERROR(N'Code not valid until %s', 16, 1, CAST(@starttimestamp AS VARCHAR));
产生一个错误说Incorrect syntax near 'CAST'.
和Incorrect syntax near '@starttimestamp'. Expecting SELECT or (
我在这里做错了什么?
Declare @starttimestamp datetime = getdate();
RAISERROR(N'Code not valid until %s', 16, 1, CAST(@starttimestamp AS VARCHAR));
产生一个错误说Incorrect syntax near 'CAST'.
和Incorrect syntax near '@starttimestamp'. Expecting SELECT or (
您不能在 raiserror 命令中执行功能。首先将您的日期转换为字符串,如下所示:
Declare @starttimestamp datetime = getdate(),
@TextDate char(19)
select @TextDate = convert(char(19),@starttimestamp,120)
RAISERROR(N'Code not valid until %s', 16, 1, @TextDate)
Declare @starttimestamp varchar(20) = cast(getdate() as varchar(20));
RAISERROR(N'Code not valid until %s', 16, 1, @starttimestamp );