Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 516.7k

Error - Conversion failed when converting the varchar value

Sep 2 2024 5:16 AM

Hi

 I am getting error - Conversion failed when converting the varchar value 'SELECT MAX(docentry) FROM Department' to data type int.

ALTER PROCEDURE [dbo].[MaxDocEntry]
	-- Add the parameters for the stored procedure here
      @TableName VARCHAR(50) 
	  ,@DocEntry INT OUTPUT
	  
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	SET @DocEntry = 'SELECT MAX(docentry) FROM ' + @TableName
END

Thanks


Answers (2)