[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 4173 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 60 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
nrn citizenship
ढ्याउ गर्दा दसैँको खसी गनाउच
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
TPS Work Permit/How long your took?
Travelling to Nepal - TPS AP- PASSPORT
कल्लाई मुर्ख भन्या ?
Morning dharahara
महँगो अण्डाको पिकल्प : कुखुरा र खोर भाडामा लिने
Travelling on TPS advance travel document to different country...
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
Informatica consultancy share
मन भित्र को पत्रै पत्र!
TPS Renewal Reregistration
Are you ready to know the truth?
चितवनको होस्टलमा १३ वर्षीया शालिन पोखरेल झुण्डिएको अवस्था - बलात्कार पछि हत्याको शंका - होस्टेलहरु असुरक्षित
Does the 180 day auto extension apply for TPS?
Another Song Playing In My Mind
lost $3500 on penny stocks !!!
Guess how many vaccines a one year old baby is given
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 [email protected] 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