DECLARE @Time char(40) SET @Time='This is the time '+convert(varchar,datepart(hour,getdate()))+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(minute,getdate())),2)+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(second,getdate())),2) Raiserror(@Time,0,1) With NowaitBut, the following would not work which I find quite sad:
DECLARE @Time char(40) SET @Time=convert(varchar,datepart(hour,getdate()))+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(minute,getdate())),2)+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(second,getdate())),2) Raiserror('This is the time '+@Time,0,1) With NowaitSo, as I mentioned in the other message, if I wish to use that kind of approach, I then have to use the additional parameters supported by the Raiseerror() to include my variable such as:
DECLARE @Time char(40) SET @Time=convert(varchar,datepart(hour,getdate()))+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(minute,getdate())),2)+':'+ RIGHT(REPLICATE('0',2)+convert(varchar,datepart(second,getdate())),2) Raiserror('This is the time %s',0,1,@Time) With Nowait