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.
Author |
Topic |
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2007-01-21 : 04:57:52
|
Master table (tlbProduct) having productID as Primary key and which acts as reference key for table (tlbCategory).Fields for tlbProduct are productID,productNameFields for tlbCategort are productID,CategoryID(primary key),CategoryName,Prizeboth productID,CategoryID are autoincrementing.but when i write two inserts simultaneously as follows insert into tlbProduct(productName)values(@productName)insert into tlbCategory(CategoryName,Prize)I get the error that ProductID value is null which is not providedBut (productId in both is autoincremented) and relationship is there in both tables How to resolve this problem without adding ProductID in second Inser?SWati |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-01-21 : 10:11:14
|
productId in both is autoincrementedrelationship is there in both tables Are you sure it's not autoincremented in tlbProduct and a foreign key in tlbCategory (sounds a bit of an odd structure - would expect CategoryID to be a foreign key in tlbCategory)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-01-21 : 13:55:13
|
If you are running SQL Server, both productID and CategoryID cannot be autoincrementing(IDENTITY) in tblCategory, since only IDENTITY column is allowed per table. More that likely, CategoryID, not productId, is the IDENTITY column for tblCategoryYou will have to supply the value for ProductID when you insert into tblCategory.CODO ERGO SUM |
 |
|
|
|
|