Solved

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

Posted on 2008-06-15
2
179 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
Comment Utility
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
Comment Utility
Thanks! Was exactly what I needed.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now