HowdyIn the following SQL I am retrieving one field in one record and that field contains a very large string. To retrieve the record I need to supply a key [PuroLogKey] - in the example below I have tried to concatenate to bring in the variable as @Key but i get an error message.DECLARE @Key varchar(10)SET @Key = '71'DECLARE @PuroMess varchar(8000)EXEC sp_executesql N'SELECT @PuroMess = RetMess FROM mtxPurolatorLog WHERE PuroLogKey = ' + @Key, N'@PuroMess varchar(8000) output', @PuroMess output
If I hard code the variable like this it works perfect:EXEC sp_executesql N'SELECT @PuroMess = RetMess FROM mtxPurolatorLog WHERE PuroLogKey = 71', N'@PuroMess varchar(8000) output', @PuroMess output
Any suggestions? I'm sure I'm overlooking the obvious...Thanks-JPR