Eng | Rus
 
Education -> Solutions -> Copy records
 
 
 
Simple Seo Solutions
SEO and Promotion
sites
VoiceNotebook.com
Speech to text for AndroidAndroid speech to text

This code shows how to copy records with some value of the primary key in the sql server table using temporary table.

SELECT * INTO #temptable FROM yourtable where tablekey=@somevalue
UPDATE #temptable set tablekey=@newvalue
INSERT INTO yourtable SELECT * FROM #temptable

Here:

yourtable is your table name
#temptable is the created temp table name
tablekey is primary key of yourtable
@somevalue is old value of the primary key
@newvalue is new value of the primary key
© prjsoft.ru