Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New ID...
Message
 
 
To
03/08/2000 21:01:37
General information
Forum:
Microsoft SQL Server
Category:
Database design
Title:
Miscellaneous
Thread ID:
00400393
Message ID:
00400838
Views:
14
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.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform