Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New ID...
Message
From
04/08/2000 11:55:25
 
 
To
03/08/2000 21:01:37
General information
Forum:
Microsoft SQL Server
Category:
Database design
Title:
Miscellaneous
Thread ID:
00400393
Message ID:
00401134
Views:
27
Hi Bob,

You are correct. I am away from the office right now to test. If the insert fails because of a constraint violation the trigger won't fire. Since it is desired that this column be a primary key it can not be checked to accept null values. Here are a couple of more options.

First, if the value being returned from the stored procedure is an integer value and the columns data type is an integer, than the identity column could be checked in the Enterprise Managers design view and let SQL handle the PK. I doubt this is the case.

Second, add some more code to the stored procedure that gets the primary key. Pass all of the values to be inserted into the table to the stored procedure and have the stored procedure do the actual insertion of records to the table, just before the insert takes place from within the stored procedure have it retrieve the PK from the other table as it does now.

I have used the second option many times (having a stored procedure do insert) and really like it. Once the stored procedure is set up correctly all I have to do is call the stored procedure and pass all the parameters to it. It is very fast and extremely reliable.

John



>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,
Previous
Reply
Map
View

Click here to load this message in the networking platform