Copy data to and from the same table and change the value of copied data in one column to a specified value

I want to copy some data in a single table in a SQL Server 2008 database and copy it into the same table and change the values in one column of the copied data to a single specified number. Here is an example, in the following table called Metric, the data is:

Key  Name    MetricValue
112    Joe      34
112    Fred     38
112    Frank    12
112    John     56
112    David    87
112    Sue      43
234    Alli     34
234    Susan    38
234    Anne     12
234    Franki   56

I want to copy all those entries with a key of 112 to Metric and assign all copied rows a Key of 387, this gives the values in the table Metric as:

Key  Name    MetricValue
112    Joe      34
112    Fred     38
112    Frank    12
112    John     56
112    David    87
112    Sue      43
234    Alli     34
234    Susan    38
234    Anne     12
234    Franki   56
387    Joe      34
387    Fred     38
387    Frank    12
387    John     56
387    David    87
387    Sue      43 

Note, this table also has a primary key which I have not shown above.

How can I do this in SQL that is compatible with SQL Server 2008.

Thanks for the help,

Tony

Answers


Here you try..

INSERT INTO Metric(Key,Name,MetricValue)
SELECT 387,Name,MetricValue
FROM Metric
WHERE Key = 112

Need Your Help

How to access Facebook private information by using ASP.NET Identity (OWIN)?

asp.net-mvc facebook-graph-api asp.net-mvc-5 owin asp.net-identity

I am developing a web site in ASP.NET MVC 5 (using RC1 version currently). The site will use Facebook for user authentication and for retrieving initial profile data.

How to create multiple columns in a div

css html text border

I was wondering how I would create multiple columns in a div. It's for a footer and I want a site map, links to social media etc.