Long time searcher first time poster.
I am trying to create a dynamic SQL script which concatenates the dynamic part into a string to form the From clause so I can declare the table name only once (in future I will add to this so that I can loop through a whole bunch of tables). However when I run the script I get the error: Incorrect syntax near '+'
DECLARE @SCode varchar(4)
DECLARE @Subcode varchar(4)
SET @SCode = 'Client1'
SET @Subcode = 'A'
SELECT MAX(dateofchange) AS Maxdate, @SCode + 'Type'.ID
FROM @SCode + 'Type'
Any help would greatly be appreciated. I'm sure the answer will be simple however I am relatievely new to the SQL game.
thanks, SSMS - 2005