Re: generate sequence col on existing table
From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 04/04/04
- Next message: John A Grandy: "Re: insert rows : generating sequence numbers"
- Previous message: Willianto: "What makes trigger doesn't fire?"
- In reply to: John A Grandy: "Re: generate sequence col on existing table"
- Next in thread: John A Grandy: "Re: generate sequence col on existing table"
- Reply: John A Grandy: "Re: generate sequence col on existing table"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 4 Apr 2004 13:19:07 +0530
hi john,
try insert query as shown in the following example.
--source table
create table table1(Col1 char(7),Col2 char(7))
insert into table1 (col1)
select 5550001 union all
select 5550007 union all
select 5550101
--destination table.
create table table2(Col1 char(7),Col2 char(7))
--insert statement
--(somehow concatenation operator (+) has got missed in earlier post.
however, try following.)
INSERT INTO Table2
(Col1,Col2)
select col1,'666' + right('0000' +
cast ((select count(*) from table1 a where LEFT(Col1,3) = '555'
and a.col1 < table1.col1) as varchar(5)), 4)
from table1
WHERE (Col1 IS NOT NULL)
and LEFT(Col1,3) = '555'
--check the data
select * from table2
-- Vishal Parkar vgparkar@yahoo.co.in
- Next message: John A Grandy: "Re: insert rows : generating sequence numbers"
- Previous message: Willianto: "What makes trigger doesn't fire?"
- In reply to: John A Grandy: "Re: generate sequence col on existing table"
- Next in thread: John A Grandy: "Re: generate sequence col on existing table"
- Reply: John A Grandy: "Re: generate sequence col on existing table"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|