Yes you're right. The Primary Key contraint on the table would prevent the insert. Because Default values must be scalar or built-in T-SQL functions (not SPs) (AFAIK), you can do one of two things:
1. Call you stored procedure before the insert and retrive a valid ID at that point.
2. Set up a scalar Default and bind it to the primary key column. Then in the insert trigger change the primary key value being inserted by calling your function.
HTH.
>Doesn't a trigger fire after a successful insert? If so, then I don't pass a Pk value, i would get a null not allowed error and the insert trigger woudn't fire.
>
>Am I wrong on this?
>
>>Bob,
>>
>>Couldn't you turn this stored procedure into an insert trigger on the table?
>>
>>John
>>
>>
>>>We have a stored procedure that gets the next available ID for a table, from a table that holds ID's... Is there any way to use this stored procedure as the default for the primary keys?
>>>
>>>Thanks,
>>>BOb
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao