Solved

How do I generate block of duplicate rows in table with one column having different value

Posted on 2008-06-15
2
186 Views
Last Modified: 2010-04-21
I have a data table called Games in an MS SQL 2005 database with a column called CaseID. CaseID is a foreign key from another datatable called Cases. I want to select a block of rows from Games where CaseID = 1 (for example), and add them into Games with CaseID = 2 (for example). I am struggling to write the SQL query to do this. I am working in Visual Web Developer 2008 Express Edition. I am building an ASP.NET 3.5 page with code in Visual Basic.
0
Comment
Question by:jat465
[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 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 125 total points
ID: 21789085
Not sure I understand the full questions here... but as a starting point,

select * from games where caseid = 1

will get that initial 'block'

not sure what you mean by "add them into Games" but think you then want to insert as caseid = 2 ?

insert games (caseid, col1,col2,col3,etc)
select 2, col1,col2,col3
from games where caseid = 1

If you can explain a bit more, step by step, then might be able to get closer to what you are really after...
0
 

Author Closing Comment

by:jat465
ID: 31467327
Thanks! Was exactly what I needed.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

615 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