I am using SQL Server 2014 and I have the following table (t1) which contains around 5,000 rows. Here is an extract of t1: n1 n2 n3 n4 n5 n6 Type 6 15 10 11 22 25 C1 2 …
Tag: sql-server
Join Two Tables Then Transpose Rows From One Table As Column Names
I’m trying to join two tables ColumnNames ID |Name |Type |Status | —————————————————– 1 |Fullname |varchar |Active 2 |Email |varchar |Active …
Insert stored procedure output data into a column of a table
I created a stored procedure in SQL Server. The stored procedure subtracts two columns in the same table. How do I insert this stored procedure data into a Inventory column of the dbo.Store table? The …
Finding the last person working on a project (grouping/having sql?)
I’m trying to figure out how to query the last person (name) who last (date) worked on a project (project). Content TableA (id) | project | name | date ———-+———-+—————…
How to get how many hour 4AM have there been between two dates in TSQL
I need to get how many of a specific hour have occurred between two dates in TSQL. Some examples: The following would give the result = 1 declare @date1 datetime = ‘2019-10-01 00:00:00.000’; declare …
Understanding window functions to deduplicate records while retaining true changes
I asked this in dba stack exchange but haven’t had any luck. Cross-posting. SQLFIDDLE I am close to figuring this out but I’m just stuck at a wall. I’m attempting to understand a post by Aaron …
How to move decimal places in SQL
I want to place a decimal between the first and second digit of the interest rate and keep 2 trailing after the decimal. How do I go about doing this? SELECT TOP 10 l.PARENTACCOUNT AS [Account Number]…
Display lookup/relational data in a v-data-table with Vue and SQLServer
I created a Node App with Vue.js, Vuetify (Client side of app) and Express (Server side of App) and the data is stored in a SQL Server database (relational database). Everything is up and running on …
How to transpose NULL value to 00:00
I have a view that gets data from an internet database. The view I created works, but when there is no data (NULL) I need it to return 00:00. How can I achieve this? Using SSMS I am getting the starttime of booked resources. I already get them in the right way. But sometimes it returns NULL. I searched the
Insert into sql server table, using subquery returning more than 1 value
I have the following tables table1 table2 table3 I want for every id in table2 where condition is true, to insert 2 rows in table1. The rows should have the table2.id and table3.id ( for all ids in table3) Here is my script so far. The expected result should be something like this: table1 id | w_id | w_check_…