RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums

Trigger help

Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,166
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Trigger help

  #5  
Apr 3rd, 2007
In fact why use a trigger OR a function. Consider this:

create table #exam 
(
	e_id int identity(1,1) primary key,
	e_score int,
	e_note nvarchar(4)
)

create table #score
(
	score_id int identity(1,1) primary key,
	score int
)

declare @score int 
set @score = 10

while @score <= 100
begin 
	insert into #score(score)
	values (@score)
		
	set @score = @score+10
end

insert into #exam(e_score, e_note) 
values (50, case when 50 <= 50 then 'Half' else 'Full' end)

insert into #exam(e_score, e_note) 
select score, case when score <= 50 then 'Half' else 'Full' end 
from #score

select * from #exam

drop table #exam
drop table #score
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:46 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC