February 29, 2008 at 10:52 am
I am new to sql server but have some background with SQL Statements.
I have two tables:
leagueplayers / leagueteam
ID / ID
leaguename / pclass
userID / pname
leagueplayer / pID
playerID / user
approved / points
leaguedesc / ltID
A league creator has control of the leagueplayers table and provides a leaguename (league ID #) and League Description
the userid in this table is the league creators.
A player can view leagueplayers, the league names and desc. then enter a leagueplayer name and playerID.
The league creator approves the player by selecting yes in the approved field (bit). At this time I need the lteam table ltID (int) field to be updated with the leaguename (int) where playerID from leagueplayers =pID from lteam.
I have read about triggers and am wary since the League Creator must update the table with the leaguename and description. Unless a trigger can be called only when a specific filed is updated. Is there a better way to do this? Any help would be appreciated.
February 29, 2008 at 12:08 pm
the trigger can limit it's actions based on fields. you'd just have a
[font="Courier New"]create trigger trigger_name on table_name
after update as
begin
if update(column_name)
begin
...
end
end[/font]
February 29, 2008 at 12:24 pm
Trigger could help you here pretty good but just keep in mind that in 2005, Triggers work by using Row Level version. That would mean increase use of TempDB.
-Roy
February 29, 2008 at 2:03 pm
You could just as easily (and more preferably in my opinion) create a stored procedure to do all of this for you. Instead of updating your Approved field and having the trigger perform your subsequent data modifications, create a stored procedure that will be called to update the Approved field and then make all corresponding data modifications.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply