[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 4859 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
TPS Re-registration case still pending ..
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
TPS EAD auto extended to June 2025 or just TPS?
nrn citizenship
Toilet paper or water?
Mamta kafle bhatt is still missing
ढ्याउ गर्दा दसैँको खसी गनाउच
ChatSansar.com Naya Nepal Chat
whats wrong living with your parents ?
TPS advance parole Travel document i-131, Class of Admission ?
Tourist Visa - Seeking Suggestions and Guidance
Now Trump is a convicted criminal .
Ajay Kumar Dev sentenced to 378 yrs
Biden said he will issue new Employment visa for someone with college degree and job offers
Why Americans reverse park?
Problems of Nepalese students in US
Nepali Passport Renewal
lost $3500 on penny stocks !!!
Biden out, Trump next president, so what’s gonna happen to TPS, termination?
They are openly permitting undocumented immigrants to participate in federal elections in Arizona now.
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