﻿<?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 2005 / Development  / How to write Update query for this scenario / 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>Fri, 24 May 2013 00:07:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to write Update query for this scenario</title><link>http://www.sqlservercentral.com/Forums/Topic1382344-145-1.aspx</link><description>I can help you to write the update statement. But I would like to know why are you doing this? This will help you with 3 days but what happens with a whole month? or a whole year? Why do you have this table design?You shouldn't store values that way, to show the results in a report would be ok (even if some people say it should be done in the front end).Please, review the requirements and then confirm you need to do this.</description><pubDate>Thu, 08 Nov 2012 08:02:48 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>RE: How to write Update query for this scenario</title><link>http://www.sqlservercentral.com/Forums/Topic1382344-145-1.aspx</link><description>[quote][b]kak.mca (11/8/2012)[/b][hr]RowId	EName	Project	Time part	HoursWorked	[14 Jan]	[15 Jan]	[16 Jan]1	Emp 1	Project 1	14/1/2010	7.0			2	Emp 2	Project 2	15/1/2010	8.0			3	Emp 1	Project 1	16/1/2010	8.0			From the above table:The above table is showing likeEmp 1 has worked for 7.0 hours on Project 1 on 14/1/2010.Emp 2 has worked for 8.0 hours on Project 2 on 15/1/2010.Emp 1 has worked for 8.0 hours on Project 1 on 16/1/2010.I want to update the above table like below:I want to update the column [14 Jan] column first row with 7.0 for Emp 1I want to update the column [15 Jan] column second row with 8.0 for Emp 2I want to update the column [16 Jan] column third row with 8.0 for Emp 1Hence the result should be:RowId	EName	Project	Time part	HoursWorked	[14 Jan]	[15 Jan]	[16 Jan]1	Emp 1	Project 1	14/1/2010	7.0	7.0		2	Emp 2	Project 2	15/1/2010	8.0		8.0	3	Emp 1	Project 1	16/1/2010	8.0			8.0Can anybody please suggest me how to write the query for the same in SQL Server 2005?[/quote]From what you posted it is nearly impossible to determine what you are trying to do or how to write the code. We would need ddl (create table statements), sample data (insert statements) and desired output based on the sample data. Take a look at the first link in my signature for best practices when posting questions.</description><pubDate>Thu, 08 Nov 2012 07:50:18 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>How to write Update query for this scenario</title><link>http://www.sqlservercentral.com/Forums/Topic1382344-145-1.aspx</link><description>RowId	EName	Project	Time part	HoursWorked	[14 Jan]	[15 Jan]	[16 Jan]1	Emp 1	Project 1	14/1/2010	7.0			2	Emp 2	Project 2	15/1/2010	8.0			3	Emp 1	Project 1	16/1/2010	8.0			From the above table:The above table is showing likeEmp 1 has worked for 7.0 hours on Project 1 on 14/1/2010.Emp 2 has worked for 8.0 hours on Project 2 on 15/1/2010.Emp 1 has worked for 8.0 hours on Project 1 on 16/1/2010.I want to update the above table like below:I want to update the column [14 Jan] column first row with 7.0 for Emp 1I want to update the column [15 Jan] column second row with 8.0 for Emp 2I want to update the column [16 Jan] column third row with 8.0 for Emp 1Hence the result should be:RowId	EName	Project	Time part	HoursWorked	[14 Jan]	[15 Jan]	[16 Jan]1	Emp 1	Project 1	14/1/2010	7.0	7.0		2	Emp 2	Project 2	15/1/2010	8.0		8.0	3	Emp 1	Project 1	16/1/2010	8.0			8.0Can anybody please suggest me how to write the query for the same in SQL Server 2005?</description><pubDate>Thu, 08 Nov 2012 02:33:22 GMT</pubDate><dc:creator>kak.mca</dc:creator></item></channel></rss>