Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Creating a table name using a variable

Author  Topic 

jstrangeway
Starting Member

9 Posts

Posted - 2005-03-31 : 09:07:37
Can anyone tell me how to create a table name based off of a variable without putting the whole statement in a string and executing the whole line.

@tablename = 'Joe'

Select *
Into @tablename
from sourcetable

Any help would be appreciated

Thanks
James

mr_mist
Grunnio

1870 Posts

Posted - 2005-03-31 : 09:10:52
You can't, you have to use dynamic SQL as you were saying you don't want to do.

But you should reconsider this anyway. Creating tables like this is a fast way to ensuring a loss of control over your server.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -