November 8, 2002 at 8:24 am
Hi,
Can anybody help ?
I want to set a column to true if the I.company_name contains a particular word e.g. If a user types in UNIVERSITY I would like the I.education column to be set to True.
NEW SQL 2000 USER !
Thanks...
CREATE TRIGGER TR_InsertUpdate1 ON dbo.tblAddress
FOR INSERT, UPDATE
AS
BEGIN
UPDATE tblAddress SET
company_name = RTRIM(LTRIM(UPPER(I.company_name))),
FROM tblAddress AS T INNER JOIN Inserted AS I
ON T.address_id = I.address_id
END
November 8, 2002 at 8:40 am
Hope this works for you.
CREATE TRIGGER TR_InsertUpdate1 ON dbo.tblAddress
FOR INSERT, UPDATE
AS
DECLARE @CN VARCHAR(50), @ID INT
SELECT @CN = Company_Name, @ID = address_id FROM Inserted
IF @CN = 'UNIVERSITY'
BEGIN
UPDATE tblAddress SET
Column = 'TRUE'
WHERE address_ID = @ID
END
November 8, 2002 at 3:41 pm
Can you please send the reply's to the form in the future.
November 11, 2002 at 11:37 am
MKumari,
Your solution assumes that only one record has been inserted/updated.
create trigger TR_InsertUpdate1 on dbo.tblAddress
for insert, update
as
begin
update dbo.tblAddress
set education = 'True'
from dbo.tblAddress a
join inserted i on i.Primary = a.Primary
where i.Company_Name = 'UNIVERSITY'
-- i.Company_Name like '%UNIVERSITY%'
-- (if you prefer)
end
Steve Hendricks
MCSD, MCDBA
AFS Consulting Group
(949) 588-9800 x15
Steve Hendricks
MCSD, MCDBA
Data Matrix
shendricks@afsconsulting.com
(949) 588-9800 x15
November 12, 2002 at 9:49 am
shendricks,put this into a cursor,if you want to do the bulk insert/update and want to fire the trigger.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy