SQL: How to view a date range and then edit the fields in records

Hi Guys,


I want to run a query in sql where it finds a date range for example:

from date: 21/8/2011 to 23/9/2011

and then i want to edit the values in this date range.


Can someone please tell which query to run.

Many Thanks!
J3D1-KN1G1-1tAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
SELECT * FROM YourTableNameGoesHere WHERE YourDateColumn BETWEEN '20110821' AND '20110923'

That makes the assumption you are using a date column and not a datetime column with time other than midnight.
J3D1-KN1G1-1tAuthor Commented:
ok great that finds the values in the date range, how do i edit the found records?
jogosCommented:
How you edit your records? The questions is which change and how do you want it.

linear change

update yourtable
set col1 = 'x'
where yourdate between .. and ...

row by row
-> cursor loop: query to select + sql code to produce the changes + update-statement to put it in database

by application
->  query to find your records, show them in application where you can modify + update when changede

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
J3D1-KN1G1-1tAuthor Commented:
Cheers for the responses, I basically want to edit rows in the found set just like how you can do it via right clicking on a table and selecting "Edit top 200 rows)

Hope that makes sense

Many Thanks
AlokJain0412Commented:
Hi

You can do something similar to what you want. Right click on a table and select "edit top 200 rows" (if you are on SQL Server 2008) or "open table" in SQL Server 2005. Once you get there, there is a button on the top that says "SQL"; when you click on it, it lets you write an SQL statement and you can edit the results of it if you click a cell you want to change.

Hope its your requirement
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.