Posted by: the_hareeb August 29, 2010
SQL server t-sql help please
Login in to Rate this Post:     0       ?        
Hi, I am new to T-SQL and looking for some help on a t-sql. your help is very much appreciated.


i want my update to update table1 accoirding this View (see attatched pic, name it thisView). table1 has the primary key of New_battelleId. I want my update to be something like this..

update table1
set new_batChase1Req1Mailed(**condition described below)=getDate()
where new_battelleId=thisView.new_battelleId

There are more columns to this view, only few are shown here:
new_batChase1Req1Mailed,new_batChase1Req2Mailed,new_batChase1Req3Mailed,
new_batChase2Req1Mailed,new_batChase2Req2Mailed,new_batChase1Req1Mailed,
new_batChase3Req1Mailed,new_batChase3Req2Mailed,new_batChase3Req1Mailed

notice how each 'Chase' has 3 'Req' each.

condition to update**
So basicly, If the chase is 1 in thisView, I want to update table1's new_batChase1Req1Mailed or new_batChase1Req2Mailed or
new_batChase1Req3Mailed. The alrogorithm is if all three requests are null, put date into req1.
if there is date in req1, the update req2(req3 will be null). If both req1 and req2 have dates then 
update req3 with the date. you get the picture.

I want similar thing to happen for req1,req2 and req3 for chase2 and chase3 also, depending on the
chase value from thisView.

thanks for help.




Last edited: 29-Aug-10 10:56 PM
Last edited: 29-Aug-10 10:56 PM
Last edited: 29-Aug-10 10:58 PM
Read Full Discussion Thread for this article