what you have to do is using a dianamic sql.
its simple.
e.g. we have a table t1 with whatever columns it has.
declare @strSql varchar(1000)--whatever size you feel suitable
declare @tName varchar(100)
set @tName='d1' --here I assign it you may pass it as parameter to a sp where you do this whole code
set @strSql='select * into '+@tName+' from t1' -- construct the sql and then
execute(@strSql) --execute it
here I use select into; for this you must set selectinto/bulkcopy option to true in database options
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.