I have the following table:
Table name: RR
columns:
Subject (varchar (35), Null)
Topic (varchar (35), Null)
RD (text, null)
RR (text, null)
Picture (varchar (50), Null)
Video (varchar (50), Null)
RRID (int, Not Null)
TSTAMP (datetime, Null)
RRCount (int, Not Null)
This table stores common information used in resolving technical problems based on Subject and Topic. However, I've now created a Subject/Topic where I want to copy all the data that corresponds to another Subject/topic.
Example:
There are 35 rows that correspond to Subject = 'Publisher01' and Topic = 'Subcategory03'. I want to create 35 new rows that contain the same RD and RR data, but have Subject = 'Publisher02' and Topic = 'Subcategory07'. Highest current RRID = 5008
I cannot figure out how to write that query. I apologize in advance for the fact that this is, no doubt, a seriously beginner question.
Hi,
would be nice to have some DDL on hand to see your additional table information and some expected results, but anyway:
if you just want to copy these rows (I don′t know what you mean by RRID ?!) the easiest insert statement is:
INSERT INTO RR
(...collist....,Subject,Topic )
SELECT
...collist...,'Publisher02','Subcategory07'
FROM RR
WHERE = 'Publisher01' and
Topic = 'Subcategory03'
HTH, jens Suessmeyer.
http://www.sqlserver2005.de
No comments:
Post a Comment