I used this from a fellow co-worker see if it will be of any use to you
If the table name(s) is(are) going to be variable, you will need to use dynamic SQL. For example:
Code:
CREATE PROCEDURE whatever
@newTable VARCHAR(40),
@oldTable VARCHAR(40)
AS
EXEC('SELECT * INTO ' + @newTable + ' FROM ' + @oldTable + ' WHERE 1 = 0')
EXEC('ALTER TABLE ' + @newTable ' ADD newColumn newDataType, ...')
Jaime E. Maccou