Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
adnan8t2
Starting Member
6 Posts |
Posted - 2013-01-23 : 06:57:20
|
Hi there,I've a BillDate as date, and a Mark as bit column in First table.(Mark=0 by default)In Second table I've FromDate as date, and ToDate as date Column.I want to set Mark=1 if BillDate is exists between FromDate & ToDateLet Say In First Table the data is----------------------------BillDate | Mark----------------------------2012-11-10 11:15:30 | 02012-12-12 09:00:00 | 0In Second Table the data is---------------------------------------------FromDate | ToDate---------------------------------------------2012-11-01 07:00:00 | 2012-11-09 23:59:592012-12-08 07:00:00 | 2012-12-15 23:59:59So in the above scenario only the second row from First tablewhich is having, BillDate->2012-12-12 09:00:00 will be Mark as 1because it comes between second row of second tableI hope I've explained my scenario, |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-23 : 07:02:24
|
[code]UPDATE t1SET Mark=1FROM table1 t1JOIN table2 t2ON t1.BillDate >= t2.FromDateAND t1.BillDate <= t2.ToDate [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|