Creating SQL table using Dynamic variable name
Posted
by megatoast
on Stack Overflow
See other posts from Stack Overflow
or by megatoast
Published on 2010-05-25T15:03:02Z
Indexed on
2010/05/25
15:11 UTC
Read the original article
Hit count: 339
I want to create backup SQL tables using variable names.
something along the lines of
DECLARE @SQLTable Varchar(20)
SET @SQLTable = 'SomeTableName' + ' ' + '20100526'
SELECT * INTO quotename(@SQLTable)
FROM SomeTableName
but i'm getting
Incorrect syntax near '@SQLTable'.
It's just part of a small script for maintence so i don't have to worry about injections.
© Stack Overflow or respective owner