阅读背景:

如何使datetime2列插入唯一

来源:互联网 

I have a table that stores stock ticks in sql server 2008. It is keyed on the symbol column and the datecolumn which is a datetime2. In a c# app inserts are sent in at a high rate to the table. Currently a row is made using the symbol and DateTime.Now and then inserted. Occationaly the situation can arise where 2 ticks for the same symbol come in and the datetime.now will return the same time, down to the millisecond. My question is how can I assure that my inserts do not use the same time for a given symbol. I fiqure I could have another unique key like rowver or somekind of autonumber in the db as one solution, but even if the insert is successful I dont want there to be duplicte times for a given symbol. I've also thought about storing the last insert time and just adding a millesecond to it if it is equal. I'm not sure the best way to go about this. Also the datetime2 seams to have more precission than the .net datetime, so don't know if I should try to solve this on the server or the client.I have a table that stores stock ticks in sql s




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: