Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2011-06-28 : 00:39:48
|
Dear All,I need to generate the Identity column value from max value of my own.Please suggest how to generate the identity column select I.*,C.* --into Map5days_interactions_callnotesfrom callnotes_MSD_AU C,Interactions_MSD_AU I where c.CONTACT_ID = I.HCP_ID and C.NOTE_DT between dateAdd(dd, -5, I.Interaction_date) and dateAdd(dd, 5, I.Interaction_date)and C.Team_Name = I.TeamNameand C.territory_position = I.callByThanks,Gangadhara MSSQL Developer and DBA |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-28 : 02:26:16
|
-- For an insertdeclare @offset intselect @offset = isnull(max(id),0) from destination_tableinsert destination_table(id, col2, col3, ...)selectrow_number() over (order by (select 1)) + @offset as id,col2,col3,...from source_table No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|