Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert into table values select - but change 1 field
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Web
Divers
Thread ID:
01531682
Message ID:
01531685
Vues:
25
>(2) is what i needed ...
>Thanks for your help
>Jaime


You're welcome

And (1) will work as well



>
>>>Hi all
>>>In a sql table, i would like to insert a subset but changing the value in just 1 field.
>>>I have a table with fields field1, field2, field3. I would like to select all rows with value 5 in field1, and insert the result rowset but changing the value of field1 to 6 prior to inserting. Is it doable in one insert command?
>>>
>>>Thanks
>>>Jaime
>>
>>Jaime,
>>
>>This is vfp syntax - but I take it sqlserver as well - remove the semi colons
>>
>>
>>	create cursor pp ;
>>	(	field1	I, ;
>>		field2	I, ;
>>		Field3	I ;
>>	)
>>	insert into pp values (1, 2, 3)
>>	insert into pp values (4, 5, 6)
>>	insert into pp values (5, 6, 6)
>>	insert into pp values (5, 7, 7)
>>	
>>	&& (1)
>>	insert into pp (field1, field2, field3 ) ;
>>		select field1+1, field2, field3 ;
>>			from pp ;
>>			where	(field1 = 5)
>>	
>>	&& (2) 
>>	insert into pp (field1, field2, field3 ) ;
>>		select 6, field2, field3 ;
>>			from pp ;
>>			where	(field1 = 5)
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform