Solved

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

Posted on 2008-06-15
2
184 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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