database-agnostic

Function that creates a timestamp in c#

梦想的初衷 提交于 2019-11-26 12:52:38
问题 I was wondering, is there a way to create a timestamp in c# from a datetime? I need a millisecond precision value that also works in Compact Framework(saying that since DateTime.ToBinary() does not exist in CF). My problem is that i want to store this value in a database agnostic way so i can sortby it later and find out which value is greater from another etc. 回答1: I always use something like the following: public static String GetTimestamp(this DateTime value) { return value.ToString(

Insert into … values ( SELECT … FROM … )

落爺英雄遲暮 提交于 2019-11-25 21:42:19
问题 I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL engine of the day (MySQL, Oracle, SQL Server, Informix, and DB2). Is there a silver-bullet syntax coming from an SQL standard (for example, SQL-92) that would allow me to insert the values without worrying about the underlying database? 回答1: Try: INSERT INTO table1 ( column1 ) SELECT col1 FROM