SET @dynamicSQLCommand1 = 'SELECT @CDT = SELECT TOP 1 DataTime FROM DestinationDatabase.dbo.' + @CurrentTable + ' ORDER BY DataTime DESC ' EXEC sp_executesql @dynamicSQLCommand1, N'@CDT nvarchar(500) OUTPUT', @CDT = @CurrentDataTime OUTPUT
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)