Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Concatenate tables
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01489196
Message ID:
01489202
Vues:
59
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
>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
>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform