Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '.'.
ALTER PROCEDURE [dbo].[ClientDBRESEED] AS BEGIN DECLARE @DBName varchar(256) DECLARE @RESEEDTEXT nvarchar(max) DECLARE @VARMAXID nvarchar(max) DECLARE @RESEEDCOUNT int DECLARE @varSQL1 varchar(max) DECLARE @ParmDefinition nvarchar(500); DECLARE @retval int DECLARE @RESEED varchar(100) DECLARE @varSQL varchar(512) DECLARE @getDBName CURSOR SET @getDBName = CURSOR FOR SELECT name FROM Master.dbo.SysDatabases WHERE name LIKE 'T0%' DECLARE @GetTbName CURSOR OPEN @getDBName FETCH NEXT FROM @getDBName INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN PRINT @DBName --AcctHolder SET @VARMAXID = N'Select @id= Max(ID) from ' + @DBName + '.dbo.AcctHolder' SET @ParmDefinition = N'@id int OUTPUT' EXEC sp_executesql @VARMAXID, @ParmDefinition, @id = @retval OUTPUT PRINT @retval SET @RESEEDCOUNT = @retval + 20000 SET @RESEED = CAST(@RESEEDCOUNT AS varchar(100)) PRINT @RESEEDCOUNT SET @varSQL1 = 'DBCC CHECKIDENT (' + @DBName + '.dbo.AcctHolder, reseed, ' + @RESEED + ' )' PRINT @varSQL1 EXEC (@varSQL1) --Consent SET @VARMAXID = N'Select @id= Max(ID) from ' + @DBName + '.dbo.ConsentAnnual' SET @ParmDefinition = N'@id int OUTPUT' EXEC sp_executesql @VARMAXID, @ParmDefinition, @id = @retval OUTPUT PRINT @retval SET @RESEEDCOUNT = @retval + 20000 SET @RESEED = CAST(@RESEEDCOUNT AS varchar(100)) PRINT @RESEEDCOUNT SET @varSQL1 = 'DBCC CHECKIDENT (' + @DBName + '.dbo.ConsentAnnual, reseed, ' + @RESEED + ' )' PRINT @varSQL1 EXEC (@varSQL1) FETCH NEXT FROM @getDBName INTO @DBName END CLOSE @getDBName DEALLOCATE @getDBName END
CHECKIDENT
SET @varSQL1 = 'DBCC CHECKIDENT (''' + @DBName + '.dbo.AcctHolder'', reseed, ' + @RESEED + ' )'
PRINT
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)