Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help selecting from a row in a table and inserting a new row

Status
Not open for further replies.

Cenedra

Programmer
Jan 2, 2003
114
US
Hi everyone,

Want I need to do is basically copy a row in my table and insert it into the same table, giving it a different ID.

here is my SQL statement

insert into events (Title, [Description], Location, CreationDate, LastSavedDate, StartDate,
FinishDate, TimeId, LabelID, IsAllDay, UserID, Organization)
select Title, [Description], Location, CreationDate, LastSavedDate, StartDate,
FinishDate, TimeId, LabelID, IsAllDay, UserID, Organization
from Events
where EventID = 31

When I run this is query analyzer, I receive the message one row effected, but nothing is inserted into my table. EventID is my identity field.


After this I wanna get the @@identity of this new rown so I can assign another column a value afterwards.

Any help on why this query isn't working?

Thanks tons for the help,
Cen
 
That code should work just fine.

Are there any triggers on the table that could be causing it to roll back because of the duplicate title?

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top