﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / Updating a % of cells in a Column / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 04:35:55 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Updating a % of cells in a Column</title><link>http://www.sqlservercentral.com/Forums/Topic1422616-1292-1.aspx</link><description>Thanks Chris, Post edited.</description><pubDate>Thu, 21 Feb 2013 08:42:10 GMT</pubDate><dc:creator>wafw1971</dc:creator></item><item><title>RE: Updating a % of cells in a Column</title><link>http://www.sqlservercentral.com/Forums/Topic1422616-1292-1.aspx</link><description>[quote][b]wafw1971 (2/21/2013)[/b][hr]I have 4 million lines of code.... [/quote]Four million lines of code would keep you quiet for a while! I guess you mean four million [i]rows[/i] in a [i]table[/i]?Read the section covering SELECT TOP... in Books Online, also NTILE(). Either of these could give you a good start.</description><pubDate>Thu, 21 Feb 2013 08:34:01 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>Updating a % of cells in a Column</title><link>http://www.sqlservercentral.com/Forums/Topic1422616-1292-1.aspx</link><description>I have 4 million rows in my table with a blank column called Cancelled Bookings divided into 3 years 2010, 2011 and 2012Booking_Skey	BookingNumber	ArrivalDate	DepartureDate	BookingDate	CancelledDate	BookingValue	PitchType_Skey	Site_Skey124532	B00124532	2010-12-31	2011-01-02	2010-12-31	NULL	10.00	7	2What I need to do is create a code where I can change the % of cancelations for the year I want to update:So for 2010 I need the following--Cancelled Bookings---- 8% of the total bookings are cancelled in the Year 2010, the cancellation date can be equal too of     less than the Arrival Date and equal to or greater than the Booking Date-- 20% of the 8% are cancelled on the same day as the Arrival Date-- 20% of the 8% are cancelled the day before the Arrival Date-- 20% of the 8% are cancelled 7 days prior to the Arrival Date-- The rest of the cancellations are randomised between 1 and 90 daysUSE OccupancySELECT ArrivalDate, DATEADD(day, CASE WHEN Rand(CHECKSUM(NEWID())) BETWEEN 0 and 0.92 THEN NULL ELSECASE WHEN Rand(CHECKSUM(NEWID())) BETWEEN 0.92 and 0.94 THEN 0 ELSECASE WHEN Rand(CHECKSUM(NEWID())) BETWEEN 0.94 and 0.96 THEN -1 ELSECASE WHEN Rand(CHECKSUM(NEWID())) BETWEEN 0.96 and 0.98 THEN -7 ELSERound(Rand(CHECKSUM(NEWID())) * -90,0) END END END END, ArrivalDate) AS DaystoReduce FROM BookingsWHERE DATEPART(Year,ArrivalDate) = '2010' and CancelledDate BETWEEN ArrivalDate AND DepartureDateCan you help?ThanksWayne</description><pubDate>Thu, 21 Feb 2013 08:12:32 GMT</pubDate><dc:creator>wafw1971</dc:creator></item></channel></rss>