I want to create backup SQL tables using variable names.
something along the lines of
DECLARE @SQLTable Varchar(20) SET @SQLTable = \'SomeTableName\' +
DECLARE @MyTableName nvarchar(20); DECLARE @DynamicSQL nvarchar(1000); SET @MyTableName = "FooTable"; SET @DynamicSQL = N'SELECT * INTO ' + @MyTableName + ' FROM BarTable'; exec @DynamicSQL;
this query is correct but just use single quote at the ("FooTable")='FooTable'