SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Variable Table names passed to Proc.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shebert
Yak Posting Veteran

85 Posts

Posted - 06/22/2004 :  15:02:05  Show Profile  Reply with Quote

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

USA
37167 Posts

Posted - 06/22/2004 :  15:03:41  Show Profile  Visit tkizer's Homepage  Reply with Quote
Your only option is dynamic sql.

Tara
Go to Top of Page

shebert
Yak Posting Veteran

85 Posts

Posted - 06/22/2004 :  15:06:12  Show Profile  Reply with Quote
I was afraid of that Thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000