Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Concatenate tables
Message
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01489196
Message ID:
01489344
Views:
36
>
>DECLARE @sql varchar(MAX)
>SET @sql = 'INSERT INTO Whatever SELECT * FROM ' + @fname
>EXECUTE (@sql)
>
>
>Also
>
>-- Invalid. It's not C# or Java 
>-- While @fname != null
>-- Correct
>While @fname IS NOT NULL
>
>

Perfect thanks Sergey !!!


>>Thanks Sergey, how do loop through the list of tables ?, I've tried selecting a table name into a variable - but how do I select from a table using my variable ?
>>
>>this is what I've tried
>>
>>
>>
>>declare @fname varchar(max)
>>
>>Select @fname = min(table_name)
>>from information_schema.tables
>>where table_type = 'base table'
>>and left(table_name,3) = 'IOM'
>>
>>-- So far so good 
>>
>>While @fname != null
>>begin
>>
>>-- How do I now select from @fname into a table ?
>>
>>Select @fname = min(table_name)
>>from information_schema.tables
>>where table_type = 'base table'
>>and left(table_name,3) = 'IOM'
>>and table_name > @fname
>>
>>end
>>
>>
Regards,
Peter J. Kane



Pete
Previous
Reply
Map
View

Click here to load this message in the networking platform