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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

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)'


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"

Almighty SQL Goddess

38200 Posts

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

Go to Top of Page

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  
 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.04 seconds. Powered By: Snitz Forums 2000