Friday, February 24, 2012

Identity column

Hi All,
Is possible to have 2 identity columns on a table.
Please help.
Thanks,
JPNo, only one identity column per table is allowed.
If you want two columns, you will have to resort to having the second column
pick its value from a "RunningNumber" sort of table.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"JP" <John_p@.yahoo.com> wrote in message
news:5D3DE697-9F6E-4852-AB61-871ED3EFD1F4@.microsoft.com...
> Hi All,
> Is possible to have 2 identity columns on a table.
> Please help.
> Thanks,
> JP|||No.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"JP" <John_p@.yahoo.com> wrote in message
news:5D3DE697-9F6E-4852-AB61-871ED3EFD1F4@.microsoft.com...
> Hi All,
> Is possible to have 2 identity columns on a table.
> Please help.
> Thanks,
> JP|||No but you could use a computed column, not sure why you would want to.
create table foo0 (ident1 int identity(1,1),ident2 as ident1,name
varchar(20))
insert into foo0 select '1'
union all
select 'fifi'
union all select 'mimi'
select * from foo0
HTH
--
Ray Higdon MCSE, MCDBA, CCNA
--
"JP" <John_p@.yahoo.com> wrote in message
news:5D3DE697-9F6E-4852-AB61-871ED3EFD1F4@.microsoft.com...
> Hi All,
> Is possible to have 2 identity columns on a table.
> Please help.
> Thanks,
> JP|||Hi John,
You can't have two identity columns on one table, but you can create a
computed column with a value derived from the identity column if you need
to.
--
Jacco Schalkwijk
SQL Server MVP
"JP" <John_p@.yahoo.com> wrote in message
news:5D3DE697-9F6E-4852-AB61-871ED3EFD1F4@.microsoft.com...
> Hi All,
> Is possible to have 2 identity columns on a table.
> Please help.
> Thanks,
> JP|||No.
For your second identity column you can create a function that returns to you the max value and
work form there
-- JP wrote: --
Hi All,
Is possible to have 2 identity columns on a table.
Please help.
Thanks,
JP

No comments:

Post a Comment