Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need advise on inserting new data using select statement
Message
 
À
07/05/2006 13:26:36
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01119949
Message ID:
01119954
Vues:
12
>Hi,
>
>Currently, lot of my Stored procedure is using lot of cursor to update/insert data. I come across some articles from www.sqlservercentral on how to replace cursor with loop and select statement. The articles is excellence on opening my mind to new way of writing SQL statement but it didn't give me any guide on how to replace my code of inserting new data without using cursor or loop. Anyone know of any good way to insert new data without using cursor or loop, please share with us. Please do not use "select (columns) into (some table)" method. Thank you
INSERT INTO MyTable (field list here)
SELECT (field list that match field list above)
FROM MyOtherTable 
All valid selects can be used in that statement. You can use derived tables, joins WHEREs etc.
If you can get desired rowset with one select you can use that select to isert that Rowset into other table.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform