i believe that's because , according to SQL rules, you cannot create a parameter from appended objects. you can assign it, or build it before hand, but noty inline
declare @param varchar(200)
SET @param= 'This is a teststring to print time: ' +convert(varchar(30), getdate(), 126)
EXEC iSPRINT @param
SET @param= 'A seconde teststring to print time: ' +convert(varchar(30), getdate(), 126)
EXEC iSPRINT @param
what you could do instead, is have the proc accept , say five varchar params with optional values, then instead of concatenating in line, treat them as parameters.
the problem there, iss you still can convert a date to varchar inline as a parameter. if it's right for the process, you could append the datetime in the procedure itself.
--fails
EXEC iSPRINT 'This is a teststring to print time: ' , CONVERT(varchar(112,getdate())
--works
EXEC iSPRINT 'This is a teststring to print time: ' , 'when Spongebob','IsOn Nickelodeon'
CREATE PROCEDURE iSPRINT @s1 varchar(max),
@s2 varchar(max) = '',
@s3 varchar(max) = '',
@s4 varchar(max) = '',
@s5 varchar(max) = ''
AS
PRINT @s1 + ' ' + @s2 + ' ' + @s3 + ' ' + @s4 + ' ' +@s5 + ' '
GO
you still hit problems with
Lowell