?
Solved

sql 2008 query - search/copy tables results

Posted on 2010-01-12
3
Medium Priority
?
321 Views
Last Modified: 2012-05-08
SQL 2008 Management Studio

What I am trying to do is as follows:

1. search a table (multiple results will come back)
2. copy that tables row/record and create a new row/record in the same table -- basically cloning the information (but change a couple of columns within table with a static value).

How is type of query written in SQL please?
SELECT MasterAccount_ID, DisplayNameApp1
FROM MasterAccounts
WHERE LeadSourceProvider_ID=143

Open in new window

0
Comment
Question by:amillyard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:lof
ID: 26299490
insert into TableName (column1, column2)
select column1, column2 from Tablename
where [your conditions here]
0
 
LVL 10

Accepted Solution

by:
lof earned 2000 total points
ID: 26299495

INSERT INTO MasterAccounts (MasterAccount_ID, DisplayNameApp1)
SELECT MasterAccount_ID, DisplayNameApp1
FROM MasterAccounts
WHERE LeadSourceProvider_ID=143

Open in new window

0
 

Author Closing Comment

by:amillyard
ID: 31676448
Excellent - thank you :-)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question