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 |
|
sqlnovice1
Starting Member
34 Posts |
Posted - 2011-08-19 : 07:29:59
|
| Hi i have to generate a key in a table by way of concatination.exmaple key : CLINC:CONS:09/09/2010:CRN:15:30:00the problem i have is that i wish to show the time as the internal clock formats, in seconds past midnight so would expect to see ......exmaple key : CLINC:CONS:09/09/2010:CRN:38700Does anyone have any ideas????Thanks in advancePaul |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-19 : 07:33:17
|
| yep. just do likeDATEDIFF(ss,DATEADD(dd,DATEDIFF(dd,0,datecol),0),datecol)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sqlnovice1
Starting Member
34 Posts |
Posted - 2011-08-19 : 09:55:23
|
| Many Thanks. All sorted now. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-19 : 10:52:26
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-08-19 : 14:15:26
|
| IMO - that key doesn't look very reliable for uniqueness. Even if you included down to the milliseconds I would expect an eventual collision. If there is no natural key in the table then how about an int identity surrogate?Be One with the OptimizerTG |
 |
|
|
|
|
|