Skip to content
Advertisement

Tag: tsql

Loop in SQL and increase one field each time

Create table for store raw data: Create table for processed data: Now store raw data: I am turning a comma separated string into individual rows: Like this: value 10 2 0 95 15 I want to insert into SplittedAndProcessedData table using a loop, like this: ID count 1 8500 2 8510 3 8512 4 8512 5 8607 6 8622 Which

Date Format Convert

I am dealing with sql DB where the date is recorded in this format ‘2020-348T08:55’. I need to convert this to datetime. Please guide if there is possible way to do that? Answer With string and date/time functions extract the year and days to create a DATETIME without the time and finally add the time part: If the days part

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 this? Answer You should first insert

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

Advertisement