Friends,
I have created a new column called ID on my table. I need
to populate it with numbers from 1 to 7 million plus. so
like 1,2,3,4,5,6,.... Increments of one. Can you please
tell me what script can do an auto increment insert into
this column? Thank you.
Mary.In EM, right click on table and table design, choose the new column and set
identity with seed =1, increament = 1. It will be auto filled with integers
starting from 1.
You can also try this:
declare @.int int
set @.int = 1
while @.int <= 7000000
begin
insert into tablename (id) values (@.int)
set @.int = @.int + 1
end
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||I like this one.
use tempdb
go
set nocount on
create table test (col1 int, col2 int)
insert test values (0,1)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,6)
insert test values (0,6)
insert test values (0,6)
declare @.x int
set @.x = 0
update test
set @.x = col1 = @.x + 1
select * from test
drop table test
Mary Jassy wrote:
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||Thank you very very much.
Imma
>--Original Message--
>In EM, right click on table and table design, choose the
new column and set
>identity with seed =1, increament = 1. It will be auto
filled with integers
>starting from 1.
>You can also try this:
>declare @.int int
>set @.int = 1
>while @.int <= 7000000
>begin
>insert into tablename (id) values (@.int)
>set @.int = @.int + 1
>end
>
>"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote
in message
>news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
need[vbcol=seagreen]
so[vbcol=seagreen]
please[vbcol=seagreen]
>
>.
>|||Mary,
Just curious but of what use would a table such as this be?
Andrew J. Kelly SQL MVP
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.
Sunday, February 12, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment