• You can't use a variable in the FROM clause.

    However if this is for something like masking data on restores to dev/test, and isn't run often, you can use dynamic-SQL

    declare @cmd varchar(max)

    declare @table1 varchar(200)

    select @table1 = 'table1'

    select @cmd = ' select column1, substring (column1,1,2) + '

    + 'LEFT(REPLICATE(replace(newid(),''-'',''''),1+LEN(column1)/32),LEN(column1)-2) '

    + 'from schema1.' + @table1

    + 'where len(column1) > 30'

    Note that you can also make variables for the column and schema.