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.
| Author |
Topic |
|
paritosh
Starting Member
42 Posts |
Posted - 2012-08-28 : 03:59:19
|
| hi all,i want to generate id column values on the basis of every day.suppose table name like test andtable have column id then value of id column are today is 28-aug-2012 then values are increased after each insert like this :-table name testcolumn name ID and values are id20120828000012012082800002........2012082800002and next day it will be on new insert :-20120829000012012082900002...............and next day it will be on new insert :-20120830000012012083000002............... |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-08-28 : 04:23:24
|
| Split into two columns - you can use a calculated column to combine them if you wish.Then yoou can use a trigger to get the max value for a day and add one t oit.You could do that with the current data but it's poor design.coalesce((select max(id)%100000 from tbl where id > convert(varchar(8),getdate(),112)*100000)+1,convert(varchar(8),getdate(),112)*100000+1)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
paritosh
Starting Member
42 Posts |
Posted - 2012-08-28 : 11:33:25
|
| HI ALL PLEASE PROVIDE SOME EASY WAY IF YOU KNOWTHANKS |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-08-28 : 12:14:51
|
| Easier than I posted?Don't think it's possible to get much easier given the structure.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|