[Show all top banners]

the_hareeb
Replies to this thread:

More by the_hareeb
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 SQL server t-sql help please
[VIEWED 4154 TIMES]
SAVE! for ease of future access.
Posted on 08-29-10 10:55 PM     Reply [Subscribe]
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

 
Posted on 08-30-10 6:35 AM     [Snapshot: 78]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

  • Update Table1
    Set new_batChase1Req1Mailed
  • = Case When Coalesce(new_batChase1Req1Mailed,new_batChase1Req2Mailed,new_batChase1Req2Mailed) is null
  • then getdate() Else null End,
  • new_batChase1Req2Mailed  =
  • Case When new_batChase1Req1Mailed is not null then getdate() Else null End,
  • new_batChase1Req3Mailed  =

  • Case When
    Coalesce(new_batChase1Req1Mailed,new_batChase1Req2Mailed) is null
  • then getdate() Else null End
  • where new_battelleId = thisView.new_battelleId

 
Posted on 08-30-10 7:58 AM     [Snapshot: 103]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

thanks, I didnt know about colease. lemme try that. 
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 200 days
Recommended Popular Threads Controvertial Threads
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
शीर्षक जे पनि हुन सक्छ।
What are your first memories of when Nepal Television Began?
Sajha Poll: नेपालका सबैभन्दा आकर्षक महिला को हुन्?
ChatSansar.com Naya Nepal Chat
NRN card pros and cons?
Basnet or Basnyat ??
निगुरो थाहा छ ??
Nas and The Bokas: Coming to a Night Club near you
TPS Re-registration
अमेरिकामा छोरा हराएको सूचना
ओच्छ्यान मुत्ने समस्या ( confession )
Do nepalese really need TPS?
TPS Re-registration case still pending ..
Drawback for applying NRN card
Breathe in. Breathe out.
nrn citizenship
Democrats are so sure Trump will win
ढ्याउ गर्दा दसैँको खसी गनाउच
My facebook archive (for sale)
Nas and The Bokas: Coming to a Night Club near you
Mr. Dipak Gyawali-ji Talk is Cheap. US sends $ 200 million to Nepal every year.
Harvard Nepali Students Association Blame Israel for hamas terrorist attacks
TPS Update : Jajarkot earthquake
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters