Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a temp table dynamiclly?
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Creating a temp table dynamiclly?
Divers
Thread ID:
01058813
Message ID:
01058813
Vues:
66
The following dynamic SQL script works for creating a table on the fly but if I change the select @tmpTblNm = 'tmpABC' to select @tmpTblNm = '#tmpABC'
it will not create the temp table. Can anyone help on creating a temp table dynamiclly?

declare @tmpTblNm varchar(40),
@str varchar(1000)

select @tmpTblNm = 'tmpABC'
select @str = ''

-- Create a temp table to hold the current page of data
-- Add an ID column to track the current row
select @str = 'Create Table '+ @tmpTblNm +
' ( row_id int IDENTITY PRIMARY KEY,
customerID int,
customerName varchar(40),
address1 varchar(40),
city varchar(25) )'

exec (@str)
Software engineers are trained to read and understand code; they are not trained in mind reading. Document the purpose not just the functionality.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform