473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Id reset every 12am

I have a table named tblTransaction

ID int (auto increment)
TransactionID nvarchar(50)
TransactionDate datetime
TransactionType nvarchar(50)

now, I want my TransactionID to be in the format of <mmddyy99999999> or 'TransactionDate + ID'. But the problem is that I need to reset my seed every 12AM so that my TransactionID the next day will be 0709110 then 0709111, and so on.... Can someone help me with my problem? Thanks in advance!
Jul 8 '11 #1
2 2089
nbiswas
149 100+
I want my TransactionID to be in the format of <mmddyy99999999> or 'TransactionDate + ID'.

Solution

Expand|Select|Wrap|Line Numbers
  1. Select Cast(ID as Varchar(10)) + REPLACE(CONVERT (VARCHAR(10), TransactionDate, 101), '/', '') As TransactionID



But the problem is that I need to reset my seed every 12AM so that my TransactionID the next day will be 0709110 then 0709111

Expand|Select|Wrap|Line Numbers
  1. Run a job scheduler or a background process that will be triggered precisely at 12AM everyday
Hope you got the idea.
Jul 8 '11 #2
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. REPLACE(CONVERT(VARCHAR(10), TransactionDate, 101), '/', '')
  2. +
  3. CAST(ID - 
  4.    (SELECT MAX(ID)
  5.     FROM tblName
  6.     WHERE TransactionDate < CONVERT(DATETIME, CONVERT(VARCHAR(10), GETDATE(), 101) + ' 00:00:00.000')) AS VARCHAR(10))
Jul 8 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Kincl | last post by:
Hey, I was wondering if it's possible to reset the "auto_increment" feature in MySQL. For example, if I have a database with a list that will change every year (the old list be completely flushed...
9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
16
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number...
1
by: Mad Scientist Jr | last post by:
I don't know how this is happening, but a dropdown control I have is resetting to the 2nd value on the list anytime a postback occurs. I have no initiation code outside of If Not (IsPostBack) ...
5
by: Flip | last post by:
I have a web app running on w2k3server, and I have an application level variable for a counter. Every once in a while today (I just put this live last night), that counter value is reset to 1 when...
5
by: cotton_gear | last post by:
Hello, When I clicked on the Reset button I need to reset only few fields selectively. How do i achieve it using javascrript ? Actually, when reset is clicked, even hidden fields are reset. I...
2
by: Sheikko | last post by:
Hi, I have a class, cerated like a struc for some reasons, and I want to reset all values in it. public class MyClass { public byte Channel; public byte SatelliteID; public byte SyncFlags;...
1
by: Matt | last post by:
I have table that has the following fields: JobNumber WeekEndingDate ReportRequired_01 ReportRequired_02 every Friday morning the weekending date changes. I need to automatically generate...
10
by: craigslist.jg | last post by:
let's say I have the following text: "4,300 value / 2,000,001 something else, 3,400, 500" I'm trying to come up with a regexp which will insert a $ sign at the begining of every number. After...
2
anoble1
by: anoble1 | last post by:
Hey I am wanting to reset a date range to lets say 1/1/2008 - 12/31/2008. So when I click on reset i want it to bring those values up and limit everything by them. That way it brings up every...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.