SET @MaxId = SELECT MAX(id) FROM @tblName
DOESN'T work , i need to return maxid of a tablename that is a parameter
DOESN'T work , i need to return maxid of a tablename that is a parameter
Code:
CREATE PROCEDURE dbo.sp_SubmitRequest2 (
@tblName,
@Deadline varchar(50),
@Requested varchar(50),
@RequestedBy varchar(50),
@RequestedFor varchar(50),
@CAM varchar(50),
@CAMNAME varchar(50)
) AS
DECLARE @MaxId int
SET @MaxId = SELECT MAX(id) FROM @tblName
INSERT INTO insiteCROMO.dbo._bTickets (theTable,theTableId,Deadline,Requested,RequestedBy,RequestedFor,CAM,CAMNAME) VALUES (@tblName,@MaxId,@Deadline,@Requested,@RequestedBy,@RequestedFor,@CAM,@CAMNAME)
GO