Connecting Tech Pros Worldwide Forums | Help | Site Map

Trigger problem

Newbie
 
Join Date: Sep 2007
Location: North Myrtle Beach SC
Posts: 3
#1: Apr 22 '08
I am having a problem with the trigger listed below. The userID is retrieved ok from the inserted, but the email comes in as NULL every time to table dbo.test. But when I look at the record that was inserted into address the email is inserted.

Please help I am so frustrated.

alter Trigger [NewCustomerToLMS] on [dbo].[Address] after insert
As
begin
set nocount on
Declare @UserID int
Declare @Email varchar (100)

select @UserID = CustomerID, @Email =Email from inserted
insert test.dbo.test(name1,name2)values(@UserID,@Email)
end
go

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Apr 22 '08

re: Trigger problem


Quote:

Originally Posted by ccopinc

I am having a problem with the trigger listed below. The userID is retrieved ok from the inserted, but the email comes in as NULL every time to table dbo.test. But when I look at the record that was inserted into address the email is inserted.

Please help I am so frustrated.

alter Trigger [NewCustomerToLMS] on [dbo].[Address] after insert
As
begin
set nocount on
Declare @UserID int
Declare @Email varchar (100)

select @UserID = CustomerID, @Email =Email from inserted
insert test.dbo.test(name1,name2)values(@UserID,@Email)
end
go

You're trigger was created on table Address. This table has columns CustomerId and Email. you're inserting the value of @Email to name2 on your test table. Is this the same column you're saying that's always empty? Or you have a separate column for email?

-- CK
Newbie
 
Join Date: Sep 2007
Location: North Myrtle Beach SC
Posts: 3
#3: Apr 22 '08

re: Trigger problem


yes same column... but I found the answer.. it wasnt in my trigger design but in the way the application saved data to the table. ty
Reply


Similar Microsoft SQL Server bytes