Skip to content

Tag: sql-server

SUM over datedifference?

Lets say I have the following records with column datetime dtTime quantity 2020-12-10 19:21:52.293 1 2020-12-10 19:21:52.323 2 2020-12-10 19:21:53.293 1 2020-12-10 19:21:58.293 1 2020-12-10 19:…

Select only the records with same values

I am working on a SQL statement that will become a part of a view. What I need is to extract only the records that have the same unique key twice. The query looks like below right now. The result I get from the query above is: I need to modify the SQL statement so that the end result is

Insert into a table in another database after first deleting

I have two databases that have same tables on those. First I had to delete all the data in employee_table in Database_1. Then after that I need to insert data in the employee_table in Database_2 to the employee_table in the Database_1. I am using SQL Server Management Studio 2017. Is there any solution for th…

Conditional Inner Join with two Functions

I have two functions. I need to decide whether to join with these two based on a BIT Value. Basically if BIT=0 join with function 1 else join with function 2 I tried putting an IF Clause .. but it does not seem to work. What is the proper way to do it? Answer Just add your static condition as