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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sql Query

Author  Topic 

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-23 : 00:59:43
Hi,

I am trying to Insert Max(RecordID) into the Table Kit_Info
when i do the bulk insert from ST_Info into Kit_info using DTS. I know in Sql Server2000 there is a Identity Column which increments the RecordID, But for some reasons i should not use that. When i use the below query it is incrementing all the records with the same number. I want the RecordID in the Incrementing Order. Any Idea.?
Thx

INSERT INTO Kit_Info(media,recdate,RecordID)
SELECT media,recdate,(select max(RecordID) + 1 from Kit_Info) FROM ST_Info

As it is a bulk insert this query is not working. any idea.?
Thx

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-23 : 01:18:39
Try

INSERT INTO Kit_Info(media,recdate)
SELECT media,recdate FROM ST_Info

Declare @i int
select @i=max(RecordID) from Kit_Info

Update Kit_info
set RecordId=@i,@i=@i+1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-26 : 12:44:05
quote:
Originally posted by madhivanan

Try

INSERT INTO Kit_Info(media,recdate)
SELECT media,recdate FROM ST_Info

Declare @i int
select @i=max(RecordID) from Kit_Info

Update Kit_info
set RecordId=@i,@i=@i+1

Madhivanan

Failing to plan is Planning to fail




Hi,
I tried this,It is incrementing all Recid's. I just want to increment the last imported one's.
Thx
Go to Top of Page
   

- Advertisement -