Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Comparing Existing To New Values

Author  Topic 

Liquid
Starting Member

4 Posts

Posted - 2003-02-13 : 05:34:10
Hi

In PL/SQL I can use the :NEW.User_ID etc.

I don't think this is possible in SQL Server 7 is it?

Is it as simple as comparing, for e.g. CHECK User_ID=User.User_ID,
or WHERE Firstname=Employee.Firstname etc. ?

Thanks

Robwhittaker
Yak Posting Veteran

85 Posts

Posted - 2003-02-13 : 07:06:57
At what point do you want to do this? You can compare new values in a trigger before the update happens by selecting the column names from the "inserted" table. Check Books On Line for details

However if you want to do this after the update, I think need to store the last value in a history column/table

Go to Top of Page

Liquid
Starting Member

4 Posts

Posted - 2003-02-13 : 09:20:36
Hi

It's for comparing the user's log in against existing data in the User's table.

Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2003-02-13 : 10:11:24
Would the use of a timestamp column be a viable solution for your needs?

Go to Top of Page

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2003-02-14 : 00:13:33
SQL Server 7 triggers are only AFTER triggers, they are fired after the action they are for e.g. Update, Insert, Delete. Accessing the Inserted table in an Update trigger gives the new values of the row(s) that was updated. You can however undo the changes within the trigger by saying ROLLBACK TRAN after doing some checking code and discovering, e.g. that this user shouldn't have put the update in.

Sarah Berger MCSD
Go to Top of Page

Liquid
Starting Member

4 Posts

Posted - 2003-02-14 : 06:33:22
Hi

Perhaps I didn't explain it well enough.

I have 2 tables - Employee and Task

I want to store the Employee data in the relevant table and only reference this when updating the Task table.

I would like the employee's to input their data when they log in. I then want to check that data against the Employee table.

I'm sure it's something simple, I'm just not sure of how to approach it.

I was thinking along the lines of CHECK firstname = employee.firstname or something.

Thanks for your time.

Go to Top of Page
   

- Advertisement -