Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 logic for incement

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-08-29 : 02:23:24

i have a table
tbl_datevcno and there is one column datevcno
i want when a record is inserted in taht column than it should be in format that first the current date and
then no of inserted value.

if there is 5 insertion are made over there on date 29 aug 2012 thenvalues should
be

29auh20121
29aug20122
29aug20123
29aug20124
29aug20125

and next day on 30 aug 2012 when again 6 transaction aremade then the values should be
30auh20121
30auh20122
30auh20123
30auh20124
30auh20125
30auh20126

challenge everything

shaggy
Posting Yak Master

248 Posts

Posted - 2012-08-29 : 02:46:47
try this
select replace(convert(varchar(15),GETDATE(),106),' ','')+convert(varchar,ROW_NUMBER() over (order by object_id)) from sys.tables
Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-08-29 : 11:59:21
not works

challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-29 : 12:51:57
quote:
Originally posted by pnpsql


i have a table
tbl_datevcno and there is one column datevcno
i want when a record is inserted in taht column than it should be in format that first the current date and
then no of inserted value.

if there is 5 insertion are made over there on date 29 aug 2012 thenvalues should
be

29auh20121
29aug20122
29aug20123
29aug20124
29aug20125

and next day on 30 aug 2012 when again 6 transaction aremade then the values should be
30auh20121
30auh20122
30auh20123
30auh20124
30auh20125
30auh20126

challenge everything


is the month name change intentional from aug to auh or is it a typo?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-08-29 : 23:44:54
it is aug

challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-30 : 01:25:23
what does the last digit represent?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-08-30 : 06:44:53
Why not use ACTUAL datetime values? Then you can see which was inserted first, etc.








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page
   

- Advertisement -