Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rolling value in a test column

Status
Not open for further replies.

pabby

IS-IT--Management
Jan 5, 2004
47
GB
Hi

I have an empty column called TEST in a table. It is used so that I can manually enter a letter or a number. This is so that I can run a query i.e. select * from tbl where test = 'a'

the next day I will use 'b' then 'c' etc etc . I want to automate this and not have to manually input a,b,c, etc - sometimes I have manually entered 100 a's

Is there a way of using UPDATE and using a rolling value.

ie. update tbl set TEST = 'a' where test is NULL

then the next day it automatically goes to b then c etc

or is using letters a bad way to go about it ?

thanks,,
Paul

 
You can create a default value on the column and change that once a day

“I sense many useless updates in you... Useless updates lead to defragmentation... Defragmentation leads to downtime...Downtime leads to suffering..Defragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Why are you using a letter/number?

If all you want to do is to be able to select the entries from a specific day, create a DATETIME column with DEFAULT of GETDATE().

Then all you need to do is:
Code:
SELECT *
FROM tbl
WHERE Test >= '2005-10-18 00:00'
 AND Test <= '2005-10-19 00:00'

There might even be an easier way to check the date range. There's a couple of good FAQs about Date/Time in the MS SQL Server: Programming Forum (FORUM183).

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top