469,887 Members | 1,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,887 developers. It's quick & easy.

How to create a series of tables with a variable name?

hi all,
I am new to MSSQL and I am thinking whether I can create a table with its name containing a variable. That is , I want to create a variable number of tables depending on the parameter passed to the stored procedure. Need Help on that. Thanks in advance.
Jul 13 '07 #1
2 950
debasisdas
8,127 Expert 4TB
yes you can easily do that by little programming knowledge.
Jul 13 '07 #2
srinit
43
hi all,
I am new to MSSQL and I am thinking whether I can create a table with its name containing a variable. That is , I want to create a variable number of tables depending on the parameter passed to the stored procedure. Need Help on that. Thanks in advance.
HI
I am sending an example .It will help you
[code]
create pro pro1(@a int)
as
begin
while(@a>0)
begin
exec('create table table+'+@a)
set @a=@a-1
end
end
Jul 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Helge | last post: by
2 posts views Thread by terence.parker | last post: by
2 posts views Thread by Bruno Remeyse | last post: by
2 posts views Thread by =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.