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)
 Creating table with an Identity

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2006-12-04 : 05:20:06
I am trying to create a table with a numeric identity but generate the following error:

Msg 8183, Level 16, State 1,
only UNIQUE or PRIMARY KEY constraints can be created on computed columns, while CHECK, FOREIGN, and NOT NULL constraints require that computer columns be persisted

My T-SQL Statement (in SQL server 2005)

Select Numeric Identity(1,1) as SRN,
a.Creditor_Ref,
b.Vendor_Name
into test
from table1 a join table2 b
on a.Creditor_Ref = b.Ref

Any ideas...? Possibly incorrect syntax..?

Many thanks!!!

Dave

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 05:24:01
Select Identity(int,1,1) as SRN,
a.Creditor_Ref,
b.Vendor_Name
into test
from table1 a join table2 b
on a.Creditor_Ref = b.Ref


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2006-12-04 : 06:34:00
Thanks! Works great
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 09:29:55
Read about IDENTITY function in sql server help file

Madhivanan

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

- Advertisement -