ERROR:
Server: Msg 170, Level 15, State 1, Line 19
Line 19: Incorrect syntax near '@TableName'.
--=======================================================
BEGIN
DECLARE @LastFullUpdate datetime
,@LastIncrementalUpdate datetime
,@LastUpdatedDt datetime
,@RecordCount bigint
,@sqlRecordcount nvarchar(200)
,@sqlCreatedDt nvarchar(200)
,@TableName varchar(50)
set @TableName = 'Carriers'
-- get record count
SET @sqlRecordcount = 'Select @RecordCount = Count(*) FROM ' + @TableName
EXEC sp_ExecuteSql @sqlRecordcount, N'@RecordCount Integer Output', @RecordCount
UPDATE UpdTables
SET CMDRecordCount = @RecordCount
WHERE TableName = @TableName
Server: Msg 170, Level 15, State 1, Line 19
Line 19: Incorrect syntax near '@TableName'.
--=======================================================
BEGIN
DECLARE @LastFullUpdate datetime
,@LastIncrementalUpdate datetime
,@LastUpdatedDt datetime
,@RecordCount bigint
,@sqlRecordcount nvarchar(200)
,@sqlCreatedDt nvarchar(200)
,@TableName varchar(50)
set @TableName = 'Carriers'
-- get record count
SET @sqlRecordcount = 'Select @RecordCount = Count(*) FROM ' + @TableName
EXEC sp_ExecuteSql @sqlRecordcount, N'@RecordCount Integer Output', @RecordCount
UPDATE UpdTables
SET CMDRecordCount = @RecordCount
WHERE TableName = @TableName