i have an situation where i have a following table.
create table Bulk_Data
(
id int identity(1,1),
UserName varchar(100) not null default 'default value ',
iPartitionID int null
)
also i have an Insert trigger on Bulk_Data.
create trigger dbo.Bulk_Data_IU on Bulk_Data
AFTER INSERT
AS Begin
Merge Bulk_Data p1
using Bulk_Data p2 on p1.id = p2.id
when matched then
update set p1.iPartitionID = right(p2.id,1);
end
condition in above table is like
i have 3 column which are not depended on any values.
1] id is identity auto increment column
2] UserName is set to be default values
3] iPartitionID is based on insert in Trigger.
so my question is how should i insert the records say suppose i do not required
to insert any values in #2 i.e. in column 2 so how should i fire the insert command on table.
because insert command is important for me as i have created Insert trigger.
when i run
insert Bulk_Data(UserName) values('Suraj Sheikh')
it works fine but what if i don’t want to insert any UserName.
is this possible ?
please help me out here.
You can use a computed column instead of a trigger that updates all rows for each insert.