SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to update date fields in a table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

252 Posts

Posted - 01/16/2013 :  02:19:12  Show Profile  Reply with Quote
hello all,

in my table i have 500000 records and 2 date fileds like

date of Eligibility Coverage END
2005-11-01 00:00:00.000 2005-12-31 00:00:00.000

now my requirement is

i need to update 5000 records and 5000 records etc; with

2011-11-01 00:00:00.000 etc

for all 50000 records

now in another column i need to update columns

with 3 month difference or 6 months diff or 1 year difference..basing on the date of Eligibility column

how i need to do this one???


Flowing Fount of Yak Knowledge

2240 Posts

Posted - 01/16/2013 :  02:27:00  Show Profile  Reply with Quote
May be this?

UPDATE TableName
SET CoverageEND =
CASE WHEN DateOfEligibility = value1 THEN dateadd( mm, 3 , DateOfEligibility )
WHEN DateOfEligibility = value2 THEN dateadd( mm, 6 , DateOfEligibility )

Go to Top of Page

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 01/16/2013 :  13:50:48  Show Profile  Reply with Quote
If Bandi's solution doesn't work please provide DDL, DML and expected output. Here are some links that can help you prepare that:
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000