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)
 Variable Table names passed to Proc.

Author  Topic 

shebert
Yak Posting Veteran

85 Posts

Posted - 2004-06-22 : 15:02:05

I am building a stored procedure this is getting passes a variable table name I.E. (MyTable_34567) into @variableTable where 34567 is going to change every time the Proc. is called by the application.

The Proc must Create a table named MyTable_34567 and give attributes like TableId int identity, name varchar(100) for example.

is there any way to do this inside the stored procedure beside Dynamic SQL

declare @sql varchar(1000)
select @sql ='create table'

select @sql= @sql+ @variableTable+ ' (tableId int identity, name varchar(100)'

exec(@sql)

I beleive dynamic SQL will slow Porc. down and ths Proc. is going to be a biggie.

Any help you can think of
Thanks Steve"

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-22 : 15:03:41
Your only option is dynamic sql.

Tara
Go to Top of Page

shebert
Yak Posting Veteran

85 Posts

Posted - 2004-06-22 : 15:06:12
I was afraid of that Thanks
Go to Top of Page
   

- Advertisement -