sql - Find all records that have the same value in a field within a Trigger -
i trying write after insert trigger table
create table [dbo].[partswork]( [parts_work_id] [int] identity(1,1) not null, [experiment_id] [int] not null, [partition_id] [int] null, [sim_time] [time](7) null, [real_time] [datetime] null, [construction] [bit] null, [destruction] [bit] null, [part_id] [int] not null, ) i need find out how many rows have same assembly_id inserted set.
assembly_id field in following table :
create table [dbo].[parts]( [part_id] [int] identity(1,1) not null, [part_name] [nvarchar](50) null, [part_type] [nvarchar](50) null, [assembly_id] [int] not null, ) i need store value int in variable.
thanks,
you'd join special inserted table (only available in triggers) [dbo].[parts] count.
some thoughts:
- you have consider multi-row inserts/updates in trigger. have 2 assembly_ids example
- when assigned variable, want it? value won't visible outside trigger
- you may better stored procedure processing , use output clause data insert
Comments
Post a Comment