Skip to content
Advertisement

Tag: sql

Convert SQL Server DateTime object to BIGINT (.Net ticks)

I need to convert a DateTime type value to BIGINT type in .Net ticks format (number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001). The conversion should be perform in Sql server 2008 using T-SQL query For example: will convert to: Answer I have found a CodeProject article that may assist: Convert DateTime To .NET Ticks

SQL query to get the precision value of a column

I need a sql query that gets the precision value for certain columns.. I am mainly concerned with a decimal type column and I need the precision value for the same. I realise that it is possible to do so in certain versions and vendors of database servers. It would be nice if you could list down for a few

Drop a temporary table if it exists

I have two lines of code in SQL that create two tables on the fly, i need to do something like IF TABLE EXISTS DROP IT AND CREATE IT AGAIN ELSE CREATE IT my lines are the following ones …

Delete all records except the most recent one?

I have two DB tables in a one-to-many relationship. The data looks like this: Resultset: I want to delete all applications except for the most recent one. In other words, each student must only have one application linked to it. Using the above example, the data should look like this: How would I go about constructing my DELETE statement to

Advertisement