Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 5th, 2003, 04:06 AM
M.L.Srinivas M.L.Srinivas is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Hyderabad, India
Posts: 3 M.L.Srinivas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Update Trigger not working

Hi Friends,

The following is the code for my update trigger:


CREATE TRIGGER TransTrig ON TransTest after UPDATE AS
If UPDATE(Status)
BEGIN
declare @status nvarchar(10);
declare @audio nvarchar(20);
select @status=status,@audio=audio from transtest;
update transtest set docfilename=@audio;
if @status='T'
begin
update transtest set transbegin=getdate() where audio=@audio;
end
else
if @status='WQ'
begin
update transtest set transend=getdate() where audio=@audio;
end
else
if @status='Q'
begin
update transtest set QaBegin=getdate() where audio=@audio;
end
else
if @status='U'
begin
update transtest set Qaend=getdate() where audio=@audio;
end
END
GO

'---------
The problem in this is the value in @audio is the value last inserted value but not the value related to the record updated.

How is this possible with one select statement a value from one col of one row and the value of the other col from another row?

Please let me know how to solve and this and if you can please try to answer the question i wrote earlier?

Thanks

M.L.Srinivas

Reply With Quote
  #2  
Old December 5th, 2003, 10:25 PM
Scorpions4ever Scorpions4ever is offline
Mad Rater
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 126 Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 31 m 44 sec
Reputation Power: 8
Just a curious question. Why are you using a trigger instead of a stored procedure?
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Update Trigger not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT