• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

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!
0
J3D1-KN1G1-1t
Asked:
J3D1-KN1G1-1t
3 Solutions
 
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.
0
 
J3D1-KN1G1-1tAuthor Commented:
ok great that finds the values in the date range, how do i edit the found records?
0
 
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
0
 
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
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now