[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 6163 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
Conservative discussions
TPS Re-registration case still pending ..
TPS for Nepal likely to extend next week
सालीको चाक
ChatSansar.com Naya Nepal Chat
TPS for Venezuela is terminated, only 60 days extension for transition period
TPS to F1 Status.
TPS To F-1 COS
Venezuela TPS lawuit
tesla stock OMG !!
TPS Sakiyo Tara Case is in Court.
Got my F1 reinstatement approved within 3 months(was out of F1 for almost 2 years)
Homeland Security revokes temporary status for 532,000 Cubans, Haitians, Nicaraguans and Venezuelans
Has anyone here successfully reinstated to F-1 status after a year-long gap following a drop from F-1?
I hope all the fake Nepali refugee get deported
Court Hearing Approval.
Need Help of IT consultancies
Nepal TPS decision
Any input on remote jobs(IT related or Sales or Marketing)?
Supreme Court allows Trump to end TPS for Venezuelans
Looking for girl
Who is hottest nepali female?
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